Problem Description
N Pagodas were standing erect in Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to N. H Owever, only two of them (labelled A and B, where 1≤a≠b≤n) withstood the "Test of".
Two monks, Yuwgna and Iaka, decide to make glories great again. They take turns to build pagodas and Yuwgna takes. For each turn, one can rebuild a new pagodas labelled I (i∉{a,b} and 1≤i≤n) if there exist two pagodas standing erect, lab Elled J and K respectively, such that i=j+k or i=j−k. Each pagoda can is rebuilt twice.
This is a game for them. The monk who can not rebuild a new pagoda would lose the game.
Input
The contains an integer t (1≤t≤500) which is the number of test cases.
For the all test case, the the provides the positive integer n (2≤n≤20000) and two different integers a and b.
Output
For each test case, output the winner (' Yuwgna ' or ' Iaka '). Both of them'll make the best possible decision each time.
Sample Input
16
2 1 2
3 1 3
67 1 2
100 1 2
8 6 8
9 6 8
10 6 8
11 6 8
12 6 8
13 6 8
14 6 8
15 6 8
16 6 8
1314 6 8
1994 1 13
1994 7 12
Sample Output
Case #1: Iaka
Case #2: Yuwgna
Case #3: Yuwgna
Case #4: Iaka
Case #5: Iaka
Case #6: Iaka
Case #7: Yuwgna
Case #8: Yuwgna
Case #9: Iaka
Case #10: Iaka
Case #11: Yuwgna
Case #12: Yuwgna
Case #13: Iaka
Case #14: Yuwgna
Case #15: Iaka
Case #16: Iaka
Meaning
There are n temples that need mending for a long time, only two (marked as a,b) intact do not need to repair, there are two monks in turn to repair the N-2 temple, each monk can only repair a temple marked as I, and requirements I meet i=j+k or i=j-k, each temple can only be built once;
Among them J and K represent already built good temple, Yuwgna first, ask the last who cannot build who loses;
Like what:
Example 1, there are 3 temples, a=1,b=2, then Yuwgna can only repair a third, then Yuwgna win;
Example 2, there are 6 temples, numbered 1 2 3 4 5 6,a=2,b=3, then Yuwgna can only repair the first or fifth, if Yuwgna repaired the first, then Iaka can fix the fourth, and so on.
Ideas:
After reading, decisive game, and then find the law, If-else judge wrote five or six, made six or seven times, the results of the whole WA;
Finally, the bug has been adjusted to find that when the number of temples is 6 o'clock, if a=3,b=6, then Yuwgna no temple can be built;
Then added a judgment: processing b/a=2, each time can only repair a integer times, submit or WA;
Then find a bug: When the number of 12 o'clock, a=9,b=12, then 3, 6 can be taken;
Finally think of the gcd of A and B; gcd C of A and B, then the integer multiples of C can be taken; For example, there are 16 temples, a=8,b=12, and 4 and 16 can be taken;
The following is the AC code:
#include <stdio.h>
int f (int a,int b)
{ //gcd
int temp,r;
if (a<b)
{
temp=a;
a=b;
b=temp;
}
r=a%b;
while (R)
{
a=b;
B=r;
r=a%b;
}
return b;
}
int main ()
{
int t;
int n,i,a,b;
int j,sum;
int k;
scanf ("%d", &t);
for (i=1;i<=t;i++)
{
k=0;
scanf ("%d%d%d", &n,&a,&b);
Sum=f (a,b);
for (j=sum;j<=n;j+=sum) //j each time the GCD k++ of A and B are added
;
k-=2;
if (k%2==0)
printf ("Case #%d:iaka\n", i);
else
printf ("Case #%d:yuwgna\n", i);
}
return 0;
}