HDU 5512

http://acm.hdu.edu.cn/showproblem.php?pid=5512

gcd(a,b)的位置都是可以选的,之后判断一下奇偶

#include <iostream>
#include <cstdio>

using namespace std;

int gcd(int a, int b) {
    return a == 0 ? b : gcd(b%a, a);
}

int main() {
    int T;
    scanf("%d", &T);
    for(int cas = 1; cas <= T; cas++) {
        int n, a, b;
        scanf("%d%d%d", &n, &a, &b);
        printf("Case #%d: ", cas);
        if((n / gcd(a, b)) & 1) puts("Yuwgna");
        else puts("Iaka");
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/xiaohongmao/p/5087862.html