Pagodas
来源:互联网 发布:淘宝联盟怎么成为高佣 编辑:程序博客网 时间:2024/06/14 00:15
D - Pagodas
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescription
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\le a\neq b\le 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\not\in\{a,b\}~and~1\le i\le n) if there exist two pagodas standing erect, labelled j and krespectively, 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.
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\not\in\{a,b\}~and~1\le i\le n) if there exist two pagodas standing erect, labelled j and krespectively, 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\le t\le 500) which is the number of test cases.
For each test case, the first line provides the positive integer n~(2\le n\le 20000) and two different integers a and b.
For each test case, the first line provides the positive integer n~(2\le n\le 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
162 1 23 1 367 1 2100 1 28 6 89 6 810 6 811 6 812 6 813 6 814 6 815 6 816 6 81314 6 81994 1 131994 7 12
Sample Output
Case #1: IakaCase #2: YuwgnaCase #3: YuwgnaCase #4: IakaCase #5: IakaCase #6: IakaCase #7: YuwgnaCase #8: YuwgnaCase #9: IakaCase #10: IakaCase #11: YuwgnaCase #12: YuwgnaCase #13: IakaCase #14: YuwgnaCase #15: IakaCase #16: Iaka
题意:n座塔,除编号为a,b的塔保留下来以外,其他塔需要重建,对于已建成的塔j,k(包括a,b两塔),每次只能重建编号为j+k或j-k的塔,Yuwgna和Iaka两个僧人轮流建一座塔,Yuwgna先手,最后不能建的人输,问最终获胜的人是哪个
#include<stdio.h>#include<algorithm>using namespace std;int fun(int x,int y){int z = y-x;if(z == x)return z;if(z > x)swap(x,z);return fun(z,x); }int n,a,b;int main(){int t,text = 1;scanf("%d",&t);while(t--){scanf("%d%d%d",&n,&a,&b);if(a>b)swap(a,b);int m = fun(a,b);int cnt = n/m-2;printf("Case #%d: %s\n",text++,cnt%2 ==0?"Iaka":"Yuwgna");}return 0;}
0 0
- Pagodas
- HDU5512 Pagodas
- hdu5512-Pagodas
- Pagodas HDU
- HDU5512 Pagodas
- HDU5512--Pagodas
- 戛古 Kakku Pagodas
- HDU 5512 Pagodas
- HDU-5512 Pagodas(GCD)
- hdu 5512 Pagodas
- HDU5512 Pagodas(博弈)
- HDU 5512 Pagodas【博弈】
- HDU 5512 Pagodas
- hdoj 5512 Pagodas (gcd)
- 【HDU 5512 Pagodas】
- HDU5512(Pagodas)
- HDU 5512 Pagodas(GCD)
- hdu 5512 Pagodas gcd()
- Java注解初识
- QQ登录界面设计
- ORB-SLAM(五)优化
- HDU 5823 color II
- 面试2016/8/13
- Pagodas
- iOS获取设备APP的UUID
- 记事本界面设计
- 第3章 REST API设计
- Oracle带输入输出参数的存储过程
- 洛谷 P1006 [NOIP2008 T3] 传纸条
- 《joel说软件》读书笔记
- ionic开发笔记二:ionic2开发的Angular 2语法
- 编程语言思考系列:解释性语言,编译性语言,脚本语言