D - Pagodas
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≤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
自己设几个数模拟一下,可以发现,他们只能相差两个人的最大公约数,然后看看有奇数个还是偶数个就可以了
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(a,b) memset((a),(b),sizeof(a))
#include<vector>
typedef __int64 ll;
typedef long double ld;
const ll mod=1e9+7;
using namespace std;
const double pi=acos(-1.0);
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
bool judge(int m,int a,int b)
{
int x=gcd(a,b);
int num=m/x;
if(num&1)
return false;
else
return true;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int m,a,b;
sf("%d%d%d",&m,&a,&b);
if(judge(m,a,b))
pf("Case #%d: Iaka\n",i);
else
pf("Case #%d: Yuwgna\n",i);
}
return 0;
}
D - Pagodas的更多相关文章
- HDU 5512 Pagodas (2015沈阳现场赛,找规律+gcd)
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- Pagodas(等差数列)
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- 2015ACM/ICPC亚洲区沈阳站 Pagodas
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDU 5512 - Pagodas - [gcd解决博弈]
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5512 Time Limit: 2000/1000 MS (Java/Others) Mem ...
- Pagodas 等差数列
nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, ...
- HDU 5512 Pagodas (gcd)
题目:传送门. 题意:t组数据,每组数据给定n,a,b,a!=b,在[1,n]的这些点中,每次选取a+b或a-b或b-a点,选取过的点在下次选取的时候可以当做ab来用继续选取,谁不能继续选取谁就输,问 ...
- hdu 5512 Pagodas 扩展欧几里得推导+GCD
题目链接 题意:开始有a,b两点,之后可以按照a-b,a+b的方法生成[1,n]中没有的点,Yuwgna 为先手, Iaka后手.最后不能再生成点的一方输: (1 <= n <= 2000 ...
- HDU 5512 Pagodas
2015 ACM / ICPC 沈阳现场赛 D 题 找了一小时规律......发现是个GCD. #include<cstdio> #include<cstring> #incl ...
- ACM学习历程—HDU 5512 Pagodas(数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里 ...
随机推荐
- Spark2.2+ES6.4.2(三十二):ES API之index的create/update/delete/open/close(创建index时设置setting,并创建index后根据avro模板动态设置index的mapping)
要想通过ES API对es的操作,必须获取到TransportClient对象,让后根据TransportClient获取到IndicesAdminClient对象后,方可以根据IndicesAdmi ...
- 如何将 Java 项目转换成 Maven 项目
本文内容 Java 项目 Maven 项目 Java 项目转换成 Maven 项目 本文主要介绍如何将 Java 项目转换成 Maven 项目.首先要明确的是,用 Maven 管理 Java 项目的确 ...
- 【NIO】Java NIO之通道
一.前言 前面学习了缓冲区的相关知识点,接下来学习通道. 二.通道 2.1 层次结构图 对于通道的类层次结构如下图所示. 其中,Channel是所有类的父类,其定义了通道的基本操作.从 Channel ...
- iOS 7设计备忘单
With the release of iOS 7, app designers and developers will need to adjust their visual language to ...
- 安卓打印实现打印pdf文档
先声明一下,此处的打印非pos打印机打印和蓝牙打印机打印,如果想查找打印小票的pos打印机请进入下面的传送门,蓝牙打印目前没做过,有做过的请指教. pos打印机传送门: 1. https://www. ...
- 爬虫 需要什么样的 CPU,内存 和带宽
所有的需求都看这个图片吧,这个就是我爬取一个网站所用的服务器和服务器资源的消耗情况.
- Android源码阅读笔记二 消息处理机制
消息处理机制: .MessageQueue: 用来描述消息队列2.Looper:用来创建消息队列3.Handler:用来发送消息队列 初始化: .通过Looper.prepare()创建一个Loope ...
- ceph crush 之 crush_do_rule
crush_do_rule中,用了一个scratch空间来完成item的搜索. scratch空间总共有3个max_result这么大,并且按照max_result长度划分为三个部分(下图中的a. ...
- 【ZooKeeper】ZooKeeper入门流水记
单机模式 下载zookeeper的包 wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.ta ...
- 【Python】Python的安装与个人使用记录
下载 从官网上下载,目前,最新版是Python3,基于项目需求,我们使用的是Python2. 我是在CentOS上安装,下载的是Python-2.7.9.tgz. 安装 tar -zxvf Pytho ...