|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||256 MB||16||9||9||100.000%|
You are given some colored marbles arranged in a circle. The marbles can have three different colors: red, white and green. The marbles changes their color in each second. The new color of a marble depends on the marble right to it. The rules of changing color is as follows:
You are given a string S and an integer N. Determine the state of the marbles after N seconds. If we consider S as a character array and its length is L, then we have L marbles in the circle. Marble (i+1) is in the right side of marble i. For marble (L-1), marble 0 is in its right.
Input starts with T (T ≤ 20), the number of test cases. Each of the next T line contains S (1 ≤ |S| ≤ 20,000) and N (1 ≤ N ≤ 10^18) separated by a single space.
For each case, output “Case #X: W R G” (without quotes) in a line where X is the case number, starting from 1, followed by a single space, and W is the number of white marbles, R is the number of red marbles and G is the number of green marbles for that particular case, each separated by a single space.
5 RRGWRGW 2 WRGWRGWRGWRG 4 WGRWRGRRWGRWRG 3 RGRGWRGRG 3 RGRGRGRGWWWWRR 5
Case #1: 3 1 3 Case #2: 4 4 4 Case #3: 10 1 3 Case #4: 5 2 2 Case #5: 8 2 4