HDU 5512 Pagodas (GCD 博弈)
来源:互联网 发布:基于大数据用户画像 编辑:程序博客网 时间:2024/06/05 02:59
Pagodas
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2116 Accepted Submission(s): 1448
Problem Description
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
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 integern (2≤n≤20000) and two different integers a and b .
For each test case, the first line provides the positive integer
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
Source
2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
显然能够建的的位置在gcd(a,b)的倍数上,所以能建的位置有n/gcd(a,b) - 2个,
判断奇偶因为%2,-2无影响
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <stack>#include <cmath>#include <queue>#include <map>using namespace std;#define N 2100int n,a,b;int T;int main(){ scanf("%d",&T); for(int i=1;i<=T;i++) { scanf("%d%d%d",&n,&a,&b); int d=__gcd(a,b); d=n/d; if(d%2 == 0) printf("Case #%d: Iaka\n",i); else printf("Case #%d: Yuwgna\n",i); } return 0;}
阅读全文
0 0
- HDU 5512 Pagodas (简单博弈 gcd)
- HDU 5512 Pagodas (GCD 博弈)
- HDU 5512 Pagodas (gcd)
- HDU 5512 Pagodas【博弈】
- HDU-5512 Pagodas(GCD)
- HDU 5512 Pagodas(GCD)
- hdu 5512 Pagodas gcd()
- HDU 5512 Pagodas (GCD博弈 + 2015ACM/ICPC亚洲区沈阳站-重现赛)
- HDU 5512 Pagodas (水题+GCD )
- HDU-5512 Pagodas(GCD+找规律)
- HDU5512 Pagodas(博弈)
- hdoj 5512 Pagodas (gcd)
- hdu 5512 Pagodas(水题)
- 思维 hdu 5512(Pagodas)
- HDU 5512 Pagodas(分析)
- hdoj 5512 Pagodas 【gcd 思维】
- HDU 5512 Pagodas (博弈论、找规律)
- HDU-5512 Pagodas(规律/迭代)
- SGU 144. Meeting(概率)
- 在别人的机器上(已有自己的github帐号)提交代码到自己的github
- jvm 总体梳理
- pythonAI五子棋
- jQuery学习二-动画回调和多个动画执行
- HDU 5512 Pagodas (GCD 博弈)
- Python 进程,子进程( multiprocessing.Process() )
- org.springframework.beans.factory.BeanCreationException: Error...... java.lang.IllegalArgumentExcept
- rpm命令
- sdut 2135 数据结构实验之队列一:排队买饭
- Java利用栈解决符号匹配问题
- spring boot 集成mongo配置
- Leetcode:2. Add Two Numbers(Week 6)
- Java中单例模式