HDU 5512 Pagodas【博弈】
2016-04-09 00:22
411 查看
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5512题意:
给定集合,最初有两个数a,b,如果两个人依次使用集合中的元素相加减,如果得到的数均不在在[1,n]中,则该人输,否则将新数放到集合中,游戏继续。分析:
看8 6 8这组,发现只有偶数才能被取到,大胆猜能选的数都是最初的两个数的gcd,判断下选出的数的个数模2即可。代码:
#include<iostream> using namespace std; int gcd(int a, int b) { return b?gcd(b, a % b):a; } int main (void) { int t;cin>>t; int n, a, b; int cnt = 1; while(t--){ cin>>n>>a>>b; cout<<"Case #"<<cnt++<<": "; int ans = n / gcd(a, b); if(ans & 1) cout<<"Yuwgna"<<endl; else cout<<"Iaka"<<endl; } return 0; }
相关文章推荐
- HDU 5512 Pagodas【博弈】
- golang信号处理
- Django 数据导入
- Django创建超级管理员
- 一套关于 Django 的笔试题
- express中配置mongoose
- mongoose进阶,mongoose高级方法;默认值,模式修饰符,虚拟属性,索引;
- poj 2762 Going from u to v or from v to u? trajan+拓扑
- UVa11971 Polygon
- JZOJ 4295【NOIP2015模拟11.2】愉快的logo设计
- django-分页(Pagination)
- Codeforces 639B Bear and Forgotten Tree 3 【构造】
- DjangoGraphviz – Django
- Django--分页
- 用户登录注册(安全)(常规、FB、google、paypal) 实战
- 2016年,准备学习一下go
- Django中render_to_response和render的区别(转载)
- 译:Google的大规模集群管理工具Borg(一)------ 用户视角的Borg特性
- Django1.4.2->Django1.6.1升级分享
- Mongo 保留字段的Collection的操作