[URI Online Judge] – 1095 – Sequence IJ 1

Do a program that print the sequence like following example.


This problem has no input.


Print the sequence like example below.

Sample InputSample Output
I=1 J=60
I=4 J=55
I=7 J=50

I=? J=0

My solution:

[URI Online Judge] – 1094 – Experiments

Maria has just started as graduate student in a medical school and she’s needing your help to organize a laboratory experiment which she is responsible about. She wants to know, at the end of the year, how many animals were used in this laboratory and the percentage of each type of animal is used at all.

This laboratory uses in particular three types of animals: frogs, rats and rabbits. To obtain this information, it knows exactly the number of experiments that were performed, the type and quantity of each animal is used in each experiment.


The first line of input contains an integer N indicating the number of test cases that follows. Each test case contains an integer Amount (1 ≤ Amount ≤ 15) which represents the amount of animal used and a character Type (‘C‘, ‘R‘ or ‘S‘), indicating the type of animal:
C: Coelho (rabbit in portuguese)
R: Rato (rat  in portuguese)
S: Sapo (frog in portuguese)


Print the total of animals used, the total of each type of animal and the percentual of each one in relation of the total of animals used. The percentual must be printed with 2 digits after the decimal point.

Sample InputSample Output
10 C
6 R
15 S
5 C
14 R
9 C
6 R
8 S
5 C
14 R
Total: 92 cobaias
Total de coelhos: 29
Total de ratos: 40
Total de sapos: 23
Percentual de coelhos: 31.52 %
Percentual de ratos: 43.48 %
Percentual de sapos: 25.00 %

My solution:

How to drag your form when “formBorderStyle” was set “none”?

just use 3-M …

Add 3 events MouseDown – MouseUp & MouseMove.

declare :

Boolean flag;
int x, y;

MouseDown function:

flag = true;
x = e.X;
y = e.Y;

MouseUp function:

flag = false;

MouseMove function:

if (flag)
this.SetDesktopLocation(Cursor.Position.X – x, Cursor.Position.Y – y);

or another solution:

[code language=”java”]

using System.Runtime.InteropServices;

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;

private static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
private static extern bool ReleaseCapture();

public Form1()

private void menuStrip1_MouseDown(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)


Factorial Problems 1


Factorial of an integer is defined by the following function

f(0) = 1

f(n) = f(n – 1) * n, if(n > 0)

So, factorial of 5 is 120. But in different bases, the factorial may be different. For example, factorial of 5 in base 8 is 170.

In this problem, you have to find the number of digit(s) of the factorial of an integer in a certain base.


Input starts with an integer T (≤ 50000), denoting the number of test cases.

Each case begins with two integers n (0 ≤ n ≤ 106) and base (2 ≤ base ≤ 1000). Both of these integers will be given in decimal.


For each case of input you have to print the case number and the digit(s) of factorial n in the given base.

Sample Input:


5 10

8 10

22 3

1000000 2

0 100

Sample Output:

Case 1: 3

Case 2: 5

Case 3: 45

Case 4: 18488885

Case 5: 1


my solution:

[URI Online Judge] – 1087 – Queen

The game of Chess has several pieces with curious movements. One of them is the Queen, which can move any number of squares in any direction: in the same line, in the same column or in any of the diagonals, as illustrated by the figure below (black dots represent positions the queen may reach in one move):

The great Chess Master Kary Gasparov invented a new type of chess problem: given the position of a queen in an empty standard chess board (that is, an 8 x 8 board) how many moves are needed so that she reaches another given square in the board?

Kary found the solution for some of those problems, but is having a difficult time to solve some others, and therefore he has asked that you write a program to solve this type of problem.


The input contains several test cases. The only line of each test case contains four integers X1, Y1, X2 andY2 (1 ≤ X1, Y1, X2, Y2 ≤ 8). The queen starts in the square with coordinates (X1, Y1), and must finish at the square with coordinates (X2, Y2). In the chessboard, columns are numbered from 1 to 8, from left ro right; lines are also numbered from 1 to 8, from top to bottom. The coordinates of a square in line X and columnY are (X, Y).

The end of input is indicated by a line containing four zeros, separated by spaces.


For each test case in the input your program must print a single line, containing an integer, indicating the smallest number of moves needed for the queen to reach the new position.

Sample InputSample Output
4 4 6 2
3 5 3 5
5 5 4 3
0 0 0 0

solution here: