HDU 5512 Pagodas [数学]

http://acm.hdu.edu.cn/showproblem.php?pid=5512
#Description
输入n,a,b
表示在[1,n]区间内建宝塔
宝塔的建造规则是
如果
j,k点有宝塔
那么
新建的宝塔可以在j+k 或者 j-k
如果一个人不能再建宝塔了
那么他就输了

#Algorithm
全部
ax+by的点都可以建到
ax+by满足什么规律呢
ax+by只有可能是gcd(a,b)的倍数
那就简单了

#Code

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 20000 + 10;
void solve() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  int ans = n / __gcd(a, b);
 // cout << ans << endl;
  if (ans % 2 == 0) puts("Iaka"); else puts("Yuwgna");
}
int main() {
  //freopen("in.txt", "r", stdin);
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) {
    printf("Case #%d: ", i);
    solve();
  }
}

猜你喜欢

转载自blog.csdn.net/YYecust/article/details/51915397