Pagodas(思维)

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

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;
}




  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值