首页 > 其他 > 详细

HDU 5521 Pagodas

时间:2015-11-05 13:31:36      阅读:308      评论:0      收藏:0      [点我收藏+]

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;
}

 

HDU 5521 Pagodas

原文:http://www.cnblogs.com/zufezzt/p/4939083.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!