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

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

  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<cmath>
  5. #include<string.h>
  6. #include<algorithm>
  7. #define sf scanf
  8. #define pf printf
  9. #define pb push_back
  10. #define mm(a,b) memset((a),(b),sizeof(a))
  11. #include<vector>
  12. typedef __int64 ll;
  13. typedef long double ld;
  14. const ll mod=1e9+7;
  15. using namespace std;
  16. const double pi=acos(-1.0);
  17. int gcd(int a,int b)
  18. {
  19. return b==0?a:gcd(b,a%b);
  20. }
  21. bool judge(int m,int a,int b)
  22. {
  23. int x=gcd(a,b);
  24. int num=m/x;
  25. if(num&1)
  26. return false;
  27. else
  28. return true;
  29. }
  30. int main()
  31. {
  32. int n;
  33. cin>>n;
  34. for(int i=1;i<=n;i++)
  35. {
  36. int m,a,b;
  37. sf("%d%d%d",&m,&a,&b);
  38. if(judge(m,a,b))
  39. pf("Case #%d: Iaka\n",i);
  40. else
  41. pf("Case #%d: Yuwgna\n",i);
  42. }
  43. return 0;
  44. }

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. C#中流的读写器BinaryReader、BinaryWriter,StreamReader、StreamWriter详解【转】

    https://blog.csdn.net/ymnl_gsh/article/details/80723050 C#的FileStream类提供了最原始的字节级上的文件读写功能,但我们习惯于对字符串操 ...

  2. 【OpenCV】选择ROI区域 (转)

    问题描述:在测试目标跟踪算法时,需要选择不同区域作为目标,进行目标跟踪,测试目标跟踪的效果. 解决思路: 1.OpenCV中提供了鼠标交互控制,利用setMouseCallback()给固定的窗口设置 ...

  3. C# Chart使用总结 1 ---------关于图表数据的来源

    关于图表数据的来源: 1.通过XValueMember YValueMembers 设置 OleDbConnection conn = new OleDbConnection(connStr); Ol ...

  4. 【C语言】字节对齐问题(以32位系统为例)

    1. 什么是对齐? 现代计算机中内存空间都是按照字节(byte)划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候经常在特定的内存地址访问,这就需要各类型 ...

  5. R语言手册

    在R的官方教程里是这么给R下注解的:一个数据分析和图形显示的程序设计环境(A system for data analysis and visualization which is built bas ...

  6. Effective Java 第三版——45. 明智审慎地使用Stream

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  7. 物联网架构成长之路(18)-接阿里云OSS服务

    1.申请/购买OSS服务 在阿里云上申请/购买OSS服务, 然后在会得AccessKeyID,AccessKeySecret,bucketName 这三个东西 2.增删改查 在pom.xml文件上增加 ...

  8. 虚拟机centos 7联网设置之NAT方式

    第一步在设置虚拟机的连接模式为NAT,虚拟机是VMware12的版本 第二步在PC主机上设置网络共享 第三步将虚拟机网卡开启,默认关闭状态,开启网卡 ip link set ens32 up (ens ...

  9. 【6集iCore3_ADP触摸屏驱动讲解视频】6-5 底层驱动之SDRAM读写(下)

    源视频包下载地址: 链接:http://pan.baidu.com/s/1jIC2LKy 密码:zyn3   银杏科技优酷视频发布区: http://i.youku.com/gingko8  

  10. PaaS 应用引擎

    这里主要是梳理一下应用引擎(XXXX App Engine),它一般被归类到PaaS领域.应用引擎即提供了各种编程语言开发的应用所需的一整套运行环境:它开箱即用,你只需部署应用的代码即可,无需前期的环 ...