### Present Remotely

Send the link below via email or IM

• Invited audience members will follow you as you navigate and present
• People invited to a presentation do not need a Prezi account
• This link expires 10 minutes after you close the presentation

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

# Practical . Loops

No description
by

## Mohamed Ali

on 24 October 2013

Report abuse

#### Transcript of Practical . Loops

Practical . Loops

11498 - Division of Nlogonia
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2493
11805 - Bafana Bafana
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2905
4215 - Feynman
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3301
11332 - Summing Digits
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2307
11764 - Jumping Mario
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2864
The Background
Example
ex1)) division point = (2 , 1)
the residence = (10 , 10)
Process
The Input

The input contains several test cases. The first line of a test case contains one integer K indicating the number of queries that will be made (0 < K ≤ 103). The second line of a test case contains two integers N and M representing the coordinates of the division point (-104 < N, M < 104). Each of the K following lines contains two integers X and Y representing the coordinates of a residence (-104 ≤ X, Y ≤ 104).

The end of input is indicated by a line containing only the number zero.

The Output

For each test case in the input your program must print one line containing:

the word divisa (means border in Portuguese) if the residence is on one of the border lines (North-South or East-West);
NO (means NW in Portuguese) if the residence is in Northwestern Nlogonia;
NE if the residence is in Northeastern Nlogonia;
SE if the residence is in Southeastern Nlogonia;
SO (means SW in Portuguese) if the residence is in Southwestern Nlogonia.
The Background
Carlos Alberto Parreira, the coach of Bafana Bafana, also wants his players to practice passing a lot. That’s why, while in the training camp for soccer world cup 2010, every day he asks all of the players who are present in practice to stand in a circle and practice passing. If N players are in practice, he gives each of the players a distinct number from 1 to N, and asks them to stand sequentially, so that player 2 will stand in right side of player 1 and player 3 will stand in right side of player 2, and so on. As they are in a circle, player 1 will stand right to player N.

The rule of passing practice is, Parreira will give the ball to player K, and practice will start. Practice will come to an end after P passes. In each pass, a player will give the ball to his partner who is in his immediate right side. After P passes, the player who owns the ball at that moment will give the ball back to Parreira.

Parreira wants to be ensured that his players practice according the rule. So he wants a program which will tell him which player will give him the ball back. So after taking the ball from the same person he can be happy that, the players play according to the rules. Otherwise he will ask them to start from beginning.
Process
Input
Input starts with an integer T (T <= 1000), the number of test cases. Each test case will contain three integers, N (2 <= N <= 23), K (1 <= K <= N), P(1<=P<=200).

Output

For each test case, output a single line giving the case number followed by the Bafana player number who will give the ball to Parreira. See sample output for exact format.
The Background
We want to know number of squares in N*N square
Example
Ex 1)) You have square 2*2
Process
Input

The input contains several test cases. Each test case is composed of a single line, containing only one integer N, representing the number of squares in each side of the grid (1 ≤ N ≤ 100).
The end of input is indicated by a line containing only one zero.

Output

For each test case in the input, your program must print a single line, containing the number of different squares for the corresponding input.
The Background
We want to get summing digits of number to be one digit
Example
Ex 1)) Number = 1234567892

1+2+3+4+5+6+7+8+9+2 = 47
4+7=11
1+1=2
The Background
Can you find out the total number of high jumps and low jumps Mario has to make?
Example
EX 1)) 1 4 2 2 3 5 3 4
Process
Input

The first line of input is an integer T (T < 30) that indicates the number of test cases. Each case starts with an integer N (0 < N < 50) that determines the number of walls. The next line gives the height of the N walls from left to right. Each height is a positive integer not exceeding 10.

Output

For each case, output the case number followed by 2 integers, total high jumps and total low jumps, respectively. Look at the sample for exact format.
Sample Input

3
2 1
10 10
-10 1
0 33
4
-1000 -1000
-1000 -1000
0 0
-2000 -10000
-999 -1001
0

Sample Output

NE
divisa
NO
divisa
NE
SO
SE
Sample Input

3
5 2 5
6 3 5
4 1 3

Sample Output

Case 1: 2
Case 2: 2
Case 3: 4
number of squares in 2*2 square = 5
Sample input

2
1
8
0

Output for the sample input

5
1
204

Process
For a positive integer n, let f(n) denote the sum of the digits of n when represented in base 10. It is easy to see that the sequence of numbers n, f(n), f(f(n)), f(f(f(n))), ... eventually becomes a single digit number that repeats forever. Let this single digit be denoted g(n).

Each line of input contains a single positive integer n at most 2,000,000,000. For each such integer, you are to output a single line containing g(n). Input is terminated by n = 0 which should not be processed.
Sample input

2
11
47
1234567892
0

Output for sample input

2
2
2
2

high jumps = 4 and low jumps=2
Sample Input

3
8
1 4 2 2 3 5 3 4
1
9
5
1 2 3 4 5

Output for Sample Input

Case 1: 4 2
Case 2: 0 0
Case 3: 4 0
then (10,10) is in North East (2 , 1)
ex2)) division point = (2 , 1)
the residence = (-10 , 1)
then (-10 , 1) is in West (2 , 1)
Example
Ex1)) Number of players = 5
Parreira will give the ball to player 2
Practice will come to an end after 5 passes

1)player 2 passes to player 3
2)player 3 passes to player 4
3)player 4 passes to player 5
4)player 5 passes to player 1
5)player 1 passes to player 2

After 5 passes player 2 will give ball to Parreira
Full transcript