Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- 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
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Practical . Loops
Transcript of Practical . Loops
11498 - Division of Nlogonia
11805 - Bafana Bafana
4215 - Feynman
11332 - Summing Digits
11764 - Jumping Mario
ex1)) division point = (2 , 1)
the residence = (10 , 10)
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.
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.
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.
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).
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.
We want to know number of squares in N*N square
Ex 1)) You have square 2*2
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.
For each test case in the input, your program must print a single line, containing the number of different squares for the corresponding input.
We want to get summing digits of number to be one digit
Ex 1)) Number = 1234567892
1+2+3+4+5+6+7+8+9+2 = 47
Can you find out the total number of high jumps and low jumps Mario has to make?
EX 1)) 1 4 2 2 3 5 3 4
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.
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.
5 2 5
6 3 5
4 1 3
Case 1: 2
Case 2: 2
Case 3: 4
number of squares in 2*2 square = 5
Output for the sample input
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.
Output for sample input
high jumps = 4 and low jumps=2
1 4 2 2 3 5 3 4
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)
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