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. 05-树9 Huffman Codes及基本操作

    哈夫曼树与哈弗曼编码 哈夫曼树 带权路径长度(WPL):设二叉树有n个叶子结点,每个叶子结点带有权值 Wk,从根结点到每个叶子结点的长度为 Lk,则每个叶子结点的带权路径长度之和就是: WPL = 最 ...

  2. Android 如何保持屏幕常亮

    确认应用需要像游戏或者视频应用一样保持屏幕处于开启状态.最好的方式是在Activity中使用FLAG_KEEP_SCREEN_ON.(and only in an activity, never in ...

  3. 救基友3(三维BFS)

    救基友记3 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述   话说CZ因为不守基道.被妖怪抓走了.好基友WP在努力讨好高富帅 ...

  4. Windows 下使用 MinGW 和 CMake 进行开发

    CMake 是个非常棒的项目管理工具,这已经是毋庸置疑的. 一些小工具需要在 win 下开发,所以今天探索使用 MinGW 和 CMake 在 win 下的搭配使用.简单做记录. MinGW 使用 Q ...

  5. [转]抛弃jQuery,使用原生JavaScript

    原文链接 Document Ready 事件 在jQuery中,document.ready可以让代码在整个文档加载完毕之后执行: $(document).ready(function() { // ...

  6. CorelCAD for Mac(绘图设计软件)破解版安装

    1.软件简介    CorelCAD 是 macOS 系统上的 CAD 绘图工具,为我们提供了获取本地 DWG 格式的高性能 CAD 设计解决方案.打开.处理和保存 .DWG 文件,实现轻松协作.借助 ...

  7. 12C -- ORA-65048 ORA-65048

    创建common user的时候报错: $ sqlplus '/as sysdba' SQL*Plus: Release 12.2.0.1.0 Production on Tue Apr 18 11: ...

  8. C#-MVC开发微信应用(4)--微信门户菜单的管理操作

    最近对微信接口进行深入的研究,通过把底层接口一步步进行封装后,逐步升级到自动化配置.自动化应答,以及后台处理界面的优化和完善上,力求搭建一个较为完善.适用的微信门户应用管理系统. 在微信门户系统里面, ...

  9. memcached配置 启动

    memcached:http://memcached.org/ libevent:http://libevent.org/ #下载包 cd /opt wget https://github.com/d ...

  10. DIOCP-DIOCPv5的处理能力

    今天和BB讨论了下DiocpV5的单连接处理能力.一直没有做过这方面的测试,稍微试了一下. 把开始的时候客户端Sleep(10),为了测试处理能力,把Sleep(10)去掉了,20秒(实际应该算17秒 ...