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. C++11中的继承构造函数

    时间:2014.06.19 地点:基地 ------------------------------------------------------------------------- 一.问题描写 ...

  2. 快速过滤出完整的SQL语句

    [root@bass ca]# mysqlbinlog -- |egrep -v "^(/|SET|BEGIN|COMMITER|#|COMMIT)" >a.log [roo ...

  3. 【转】搞清楚LzoCodec和LzopCodec

    使用LZO过程会发现它有两种压缩编码可以使用,即LzoCodec和LzopCodec,下面说说它们区别: LzoCodec比LzopCodec更快, LzopCodec为了兼容LZOP程序添加了如 b ...

  4. 基于zookeeper、连接池、Failover/LoadBalance等改造Thrift 服务化

    对于Thrift服务化的改造,主要是客户端,可以从如下几个方面进行: 1.服务端的服务注册,客户端自动发现,无需手工修改配置,这里我们使用zookeeper,但由于zookeeper本身提供的客户端使 ...

  5. 浅谈Facebook的服务器架构(组图)

    导读:毫无疑问,作为全球最领先的社交网络,Facebook的高性能集群系统承担了海量数据的处理,它的服务器架构一直为业界众人所关注.CSDN博主yanghehong在他自己最新的一篇博客< Fa ...

  6. php url配置项

  7. 002servlet生命周期以及有关servlet的各种知识

    4 Sevlet的生命周期(重点) 有关servlet的类有Servlet,HttpServlet以及GenericServlet. 其实我们要写一个Servlet只要写一个类去实现Servet就可以 ...

  8. java----EL表达式

     Java Web中的EL(表达式语言)详解 表达式语言(Expression Language)简称EL,它是JSP2.0中引入的一个新内容.通过EL可以简化在JSP开发中对对象的引用,从而规范页面 ...

  9. $-------JSP中表达式语言的$特殊字符的作用

    JSP 中EL表达式用法详解 EL 全名为Expression Language EL 语法很简单,它最大的特点就是使用上很方便.接下来介绍EL主要的语法结构: ${sessionScope.user ...

  10. annexb模式

    h264有两种封装,一种是annexb模式,传统模式,有startcode,SPS和PPS是在ES中一种是mp4模式,一般mp4 mkv会有,没有startcode,SPS和PPS以及其它信息被封装在 ...