Pagodas

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2045    Accepted Submission(s): 1405

Problem Description
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 aand 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
 
Source
 
  • 签到数论题
  • 求gcd(a,b)=d,如果a和b互质则可以到达每个位置,否则总共到达位置数量为n/d
 #include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long LL ;
typedef unsigned long long ULL ;
const int maxn = 1e5 + ;
const int inf = 0x3f3f3f3f ;
const int npos = - ;
const int mod = 1e9 + ;
const int mxx = + ;
const double eps = 1e- ;
const double PI = acos(-1.0) ; int gcd(int x, int y){
return y?gcd(y,x%y):x;
}
int T, n, a, b, c, d, Yuwgna;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
while(~scanf("%d",&T)){
for(int kase=;kase<=T;kase++){
scanf("%d %d %d",&n,&a,&b);
d=gcd(a,b);
c=(n/d)-;
Yuwgna=c&;
printf("Case #%d: %s\n",kase,Yuwgna?"Yuwgna":"Iaka");
}
}
return ;
}

HDU_5512_Pagodas的更多相关文章

随机推荐

  1. 使用802.1X+FreeRadius+LDAP实现网络准入方案

    前言:在很多运维项目交流中,我们发现有一些运维团队还是在尝试使用网管或桌面管理来进行网络准入管理,但这两个技术有一定的缺点,所以本文分享一下802.1X+开源软件整合的网络准入管理的实践. 网络准入业 ...

  2. mybatis、ibatis 和spring集成

    mybatis是ibatis的升级版,spring也有自带mybatis的orm.所以,搭建ibatis的框架也会有多种方式(我这里mybatis是3.0的,ibatis是2.3的,spring是3. ...

  3. qt中的菜单QMenu QAction

    Qt中要建立菜单,有三个类很重要: QMenuBar(QWidget * parent = 0) QMenu(QWidget * parent = 0) QMenu(const QString &am ...

  4. HTML5中的拖放

    关于HTML5中的拖放 拖放(Drag 和 Drop)是一种常见的特性,即抓取对象以后拖到另一个位置,在 HTML5 中,拖放是标准的组成部分.在HTML5中用户可以使用鼠标选择一个可拖动元素,将元素 ...

  5. 记一次安装多版本php的四个雷区,你踩着了吗

    记一次安装多版本php的四个雷区,你踩着了吗   技术小疯子关注3人评论740人阅读2018-06-29 15:00:30   记一次安装多版本的php的四个雷区,你踩着了吗 需求:公司需要在同一台服 ...

  6. 解决cookie跨域访问.2

    v一.前言 随着项目模块越来越多,很多模块现在都是独立部署.模块之间的交流有时可能会通过cookie来完成.比如说门户和应用,分别部署在不同的机器或者web容器中,假如用户登陆之后会在浏览器客户端写入 ...

  7. ORDER BY 语句用于对结果集进行排序。

    ORDER BY 语句 ORDER BY 语句用于根据指定的列对结果集进行排序. ORDER BY 语句默认按照升序对记录进行排序. 如果您希望按照降序对记录进行排序,可以使用 DESC 关键字.

  8. Angular入门篇高速开发导航网

    简单介绍 AngularJS 是一个为动态WEB应用设计的结构框架,提供给大家一种新的开发应用方式.这样的方式能够让你扩展HTML的语法.以弥补在构建动态WEB应用时静态文本的不足.从而在web应用程 ...

  9. 动态向SqlParameter 里添加相应参数

    先定义一个List,然后再往List里面添加SqlParameter对象,然后将List转为SqlParameter数组即可 List<SqlParameter> ilistStr = n ...

  10. hdu 2141:Can you find it?(数据结构,二分查找)

    Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others ...