n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labelled a and b, where 1≤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) if there exist two pagodas standing erect, labelled j and k respectively, such that i=j+k or i=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) which is the number of test cases.

For each test case, the first line 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 will 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

自己设几个数模拟一下,可以发现,他们只能相差两个人的最大公约数,然后看看有奇数个还是偶数个就可以了

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(a,b) memset((a),(b),sizeof(a))
#include<vector>
typedef __int64 ll;
typedef long double ld;
const ll mod=1e9+7;
using namespace std;
const double pi=acos(-1.0);
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
bool judge(int m,int a,int b)
{
int x=gcd(a,b);
int num=m/x;
if(num&1)
return false;
else
return true;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int m,a,b;
sf("%d%d%d",&m,&a,&b);
if(judge(m,a,b))
pf("Case #%d: Iaka\n",i);
else
pf("Case #%d: Yuwgna\n",i);
}
return 0;
}

D - Pagodas的更多相关文章

  1. HDU 5512 Pagodas (2015沈阳现场赛,找规律+gcd)

    Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  2. Pagodas(等差数列)

    Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  3. 2015ACM/ICPC亚洲区沈阳站 Pagodas

    Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  4. HDU 5512 - Pagodas - [gcd解决博弈]

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5512 Time Limit: 2000/1000 MS (Java/Others) Mem ...

  5. Pagodas 等差数列

    nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, ...

  6. HDU 5512 Pagodas (gcd)

    题目:传送门. 题意:t组数据,每组数据给定n,a,b,a!=b,在[1,n]的这些点中,每次选取a+b或a-b或b-a点,选取过的点在下次选取的时候可以当做ab来用继续选取,谁不能继续选取谁就输,问 ...

  7. hdu 5512 Pagodas 扩展欧几里得推导+GCD

    题目链接 题意:开始有a,b两点,之后可以按照a-b,a+b的方法生成[1,n]中没有的点,Yuwgna 为先手, Iaka后手.最后不能再生成点的一方输: (1 <= n <= 2000 ...

  8. HDU 5512 Pagodas

    2015 ACM / ICPC 沈阳现场赛 D 题 找了一小时规律......发现是个GCD. #include<cstdio> #include<cstring> #incl ...

  9. ACM学习历程—HDU 5512 Pagodas(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里 ...

随机推荐

  1. MySQL查看当前的连接信息

    1:查看当前有多少个连接 mysql> status; Threads: 4 2:查看连接的详细信息 mysql> SHOW FULL PROCESSLIST;

  2. 将cmd中命令输出保存为TXT文本文件

    转自:https://www.cnblogs.com/hongten/archive/2013/03/27/hongten_windows_cms.html 例如:将Ping命令的加长包输出到D盘的p ...

  3. openssl - X509证书操作函数

    原文链接: http://blog.csdn.net/zqt520/article/details/26965797 现有的证书大都采用X.509规范,主要同以下信息组成:版本号.证书序列号.有效期. ...

  4. 【Vegas原创】查询SQL Server更改记录的语句

    指定数据库,然后: select Name,Create_date,Modify_Date from sys.objects where type in ('U','P', 'V','F', 'TR' ...

  5. phpmyadmin登录提示mysqli_real_connect(): (HY000/2002): No such file or directory和mysql8登录失败的问题

    网上的解决方法有很多,但都无法解决我的问题,最后在stackoverflow上找到解决方法,原文地址:https://stackoverflow.com/questions/41881123/mysq ...

  6. Java代码里利用Fiddler抓包调试设置

    Fiddler启动时已经将自己注册为系统的默认代理服务器,应用程序在访问网络时会去获取系统的默认代理,如果需要捕获java访问网络时的数据,只需要在启动java程序时设置代理服务器为Fiddler即可 ...

  7. JS中的Map和Set实现映射对象

    使用iterable内置的forEach方法 var a = ['A', 'B', 'C']; a.forEach(function (element, index, array) { // elem ...

  8. 【iCore1S 双核心板_ARM】例程一:ARM驱动三色LED

    实验原理: 通过STM32的三个GPIO驱动一个三色LED,引脚PF3接蓝色LED(ARM_LEDB), 引脚PF4接绿色LED(ARM_LEDG),引脚PF5接红色LED(ARM_LEDR),  G ...

  9. 配置Django

    第一步,安装Python,在这里下载,如果你安装在C:\Python27, 把C:\Python27;C:\Python27\Scripts;C:\Python27\Lib 加到你的Path 第二步: ...

  10. compass Errno::EACCES on line ["897"] of C: Permission denied

    具体原因不清楚,应该是与新版的sass有关. 目前的处理方法就是安装原来的版本 gem uninstall compass gem uninstall sass gem install sass –v ...