Birthday party At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute Y number of candy to X number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. Candy distribution will be sequentially starting from position Z and if past the last position then the distribution of candy continues to the first position. Write down the person in which position will get the last candy. Input Format The first line of input is T, which is the number of test cases. The second row and the next number of T rows are X, Y, Z. X is the number of people to whom the candy will be distributed. Y is the number of candy available. Z is the starting position of the person to whom the candy will be distributed. Output Format A string “Case #N: “ and a number representing the position of the person who got the last candy. Constraints 1 ≤ T ≤ 100 1 ≤ X, Y ≤ 103 1 ≤ Z ≤ X Sample Input 4 3 4 1 3 5 2 4 2 2 4 5 2 Sample Output Case #1: 1 Case #2: 3 Case #3: 3 Case #4: 2 Sample Input 2 7 19 2 3 7 3 Sample Output Case #1: 6 Case #2: 3 In the sample above, the example inputted in the case: 3 4 1 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from 1st person. So that the 1st, 2nd, 3rd person will each get one candy then return to 1st person gets the last candy. Then output 1. 4 2 2 means that there are 4 people who will be distributed candy, there are 2 candies, starting to be divided from the 2nd person. So the 2nd, 3rd person will each get 1 candy where is the last candy obtained by the 3rd person. 4 5 2 means that the candy distribution order is from the 2nd, 3rd, 4th, 1st, 2nd person to the last person who getting candy is 2nd person, then 2nd output. Notes Even though it wasn't stated in the problem, by now you should know that the advantages spaces or lines are considered WRONG ANSWER.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Birthday party

At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute Y number of candy to X number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. Candy distribution will be sequentially starting from position Z and if past the last position then the distribution of candy continues to the first position. Write down the person in which position will get the last candy.

Input Format
The first line of input is T, which is the number of test cases.
The second row and the next number of T rows are X, Y, Z.
X is the number of people to whom the candy will be distributed.
Y is the number of candy available.
Z is the starting position of the person to whom the candy will be distributed.

Output Format
A string “Case #N: “ and a number representing the position of the person who got the last candy.

Constraints
1T100
1X, Y103
1ZX

Sample Input
4
3 4 1
3 5 2
4 2 2
4 5 2

Sample Output
Case #1: 1
Case #2: 3
Case #3: 3
Case #4: 2

Sample Input
2
7 19 2
3 7 3

Sample Output
Case #1: 6
Case #2: 3


In the sample above, the example inputted in the case:
3 4 1 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from 1st person. So that the 1st, 2nd, 3rd person will each get one candy then return to 1st person gets the last candy. Then output 1.
4 2 2 means that there are 4 people who will be distributed candy, there are 2 candies, starting to be divided from the 2nd person. So the 2nd, 3rd person will each get 1 candy where is the last candy obtained by the 3rd person.
4 5 2 means that the candy distribution order is from the 2nd, 3rd, 4th, 1st, 2nd person to the last person who getting candy is 2nd person, then 2nd output.

Notes
Even though it wasn't stated in the problem, by now you should know that the advantages spaces or lines are considered WRONG ANSWER.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr