|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|5 초||512 MB||16||13||12||80.000%|
The owner of a prestigious ballroom has painted a beautiful circular clock on the dance floor, and a group of D dancers numbered 1 through D are about to literally "dance around the clock". They are standing in a circle, with dancer 1 at the 12:00 position of the circle and the other dancers going clockwise around the circle in increasing numerical order. The number of dancers is even.
The dance will go on for N turns. On the i-th turn (counting starting from 1), the following will happen:
For example, this diagram shows the initial state and two turns of a dance with eight people.
Which two dancers will be next to dancer number K when the dance is over?
The first line of the input gives the number of test cases, T. T test cases follow. Each consists of one line with three integers D, K, and N: the total number of dancers, the number of one of the dancers, and the number of turns the dance will go on for.
For each test case, output one line containing
Case #x: y z, where:
xis the test case number (starting from 1).
yis the number of the dancer who will be standing to dancer number K's left (that is, one step away in clockwise order) when the dance is over.
zis the number of the dancer who will be standing to dancer number K's right (that is, one step away in counterclockwise order) when the dance is over.
3 8 3 1 8 4 2 4 1 8
Case #1: 6 4 Case #2: 1 7 Case #3: 2 4
For Cases #1 and #2, refer to the illustration above. In Case #1, after 1 turn, dancer 6 is to dancer 3's left, and dancer 4 is to dancer 3's right. In Case #2, after 2 turns, dancer 1 is to dancer 4's left, and dancer 7 is to dancer 4's right. Remember that you're looking from the dancer's perspective; it may help to think in terms of clockwise and counterclockwise instead of left and right.
In Case #3, after eight turns, the arrangement looks the same as the initial arrangement, with dancer 2 to dancer 1's left, and dancer 4 to dancer 1's right.