nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 11 to nn. However, only two of them (labelled aa and bb, where 1≤a≠b≤n1≤a≠b≤n) withstood the test of time.
Two monks, Yuwgna and Iaka, decide to make glories great again. They take turns to build pagodas and Yuwgna takes first. For each turn, one can rebuild a new pagodas labelled i (i∉{a,b} and 1≤i≤n)i (i∉{a,b} and 1≤i≤n) if there exist two pagodas standing erect, labelled jj and kk respectively, such that i=j+ki=j+k or i=j−ki=j−k. Each pagoda can not be rebuilt twice.
This is a game for them. The monk who can not rebuild a new pagoda will lose the game.
Input
The first line contains an integer t (1≤t≤500)t (1≤t≤500) which is the number of test cases.
For each test case, the first line provides the positive integer n (2≤n≤20000)n (2≤n≤20000) and two different integers aa and bb.
Output
Two monks, Yuwgna and Iaka, decide to make glories great again. They take turns to build pagodas and Yuwgna takes first. For each turn, one can rebuild a new pagodas labelled i (i∉{a,b} and 1≤i≤n)i (i∉{a,b} and 1≤i≤n) if there exist two pagodas standing erect, labelled jj and kk respectively, such that i=j+ki=j+k or i=j−ki=j−k. Each pagoda can not be rebuilt twice.
This is a game for them. The monk who can not rebuild a new pagoda will lose the game.
Input
The first line contains an integer t (1≤t≤500)t (1≤t≤500) which is the number of test cases.
For each test case, the first line provides the positive integer n (2≤n≤20000)n (2≤n≤20000) and two different integers aa and bb.
Output
For each test case, output the winner (``Yuwgna" or ``Iaka"). Both of them will make the best possible decision each time.
思路:
找找规律,挺容易找的,
1:a,b互质的话,那么这n个数都可以,奇数就是Y,偶数就是I
2:不互质,找出gcd(a,b),n/一下就好了,然后依然时候是上面的步骤
代码:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <cctype>
#include <sstream>
#define INF 0x3f3f3f3f
typedef long long LL;
using namespace std;
const int maxn=500+5;
int t,a,b,n;
int gcd(int x,int y)
{
return y?gcd(y,x%y):x;
}
int main ()
{
//freopen ("in.txt","r",stdin);
scanf ("%d",&t);
for (int i=1;i<=t;i++){
scanf ("%d%d%d",&n,&a,&b);
int x=n/gcd(a,b);
if (x&1){
printf ("Case #%d: Yuwgna\n",i);
continue;
}
else {
printf ("Case #%d: Iaka\n",i);
continue;
}
}
return 0;
}