您的位置:首页 > 编程语言 > Go语言

HDU 5512 Pagodas

2015-11-05 12:34 561 查看
2015 ACM / ICPC 沈阳现场赛 D 题

找了一小时规律......发现是个GCD。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

int n,a,b;

int gcd(int a,int b)
{
int t;
while(b) t = a%b,a = b,b = t;
return a;
}

int main()
{
int T;
scanf("%d",&T);
for(int Case=1; Case<=T; Case++)
{
scanf("%d%d%d",&n,&a,&b);
printf("Case #%d: ",Case);
if((n/gcd(a,b)-2)%2==0) printf("Iaka\n");
else printf("Yuwgna\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: