HDU 5512 Pagodas

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
");
        else printf("Yuwgna
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/4939083.html