题意:
一共有G个子游戏,一个子游戏有Bi, Ni两个数字。两名玩家开始玩游戏,每名玩家从N中减去B的任意幂次的数,直到不能操作判定为输。问谁最终能赢。
题解:
GYM - 101147 A.The game of Osho
#include <bits/stdc++.h> using namespace std; int t; int g; int b, n; int ans; int main() { freopen("powers.in","r",stdin); scanf("%d", &t); while(t--) { ans = 0; scanf("%d", &g); while(g--) { scanf("%d%d", &b, &n); if(b&1) ans ^= n&1; else { int tt = n%(b+1); if(tt==b) ans ^= 2; else ans ^= tt&1; } } if(ans) puts("1"); else puts("2"); } }