HDU 3389 阶梯博弈变形
n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输
选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法再移动的 步数为0,然后发现以6为周期,取模就好了
/** @Date : 2017-10-14 19:18:00 * @FileName: HDU 3389 基础阶梯博弈变形.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL long long #define PII pair #define MP(x, y) make_pair((x),(y)) #define fi first #define se second #define PB(x) push_back((x)) #define MMG(x) memset((x), -1,sizeof(x)) #define MMF(x) memset((x),0,sizeof(x)) #define MMI(x) memset((x), INF, sizeof(x)) using namespace std; const int INF = 0x3f3f3f3f; const int N = 1e5+20; const double eps = 1e-8; int main() { int T; cin >> T; int cnt = 0; while(T--) { int n; scanf("%d", &n); int sg = 0; for(int i = 1; i <= n; i++) { int x; scanf("%d", &x); int c = i % 6; if(c == 0 || c == 2 || c == 5) sg ^= x; } if(sg) printf("Case %d: Alice\n", ++cnt); else printf("Case %d: Bob\n", ++cnt); } return 0; }