数字x左边有x - L个数字,右边有R - x个数字。
可以看成有两堆石子,分别有x - L个、R - x个。
玩家每次可以取多个或者取完,但至少取一个。
至此就是一个nim博弈。
考虑异或和等于0即可。
或者考虑对称博弈,每次先手取多少,对手跟着在另一边取多少,因为两边的数目一样,所以
当x - L = R - x时一定是后手Bob赢。
#include <bits/stdc++.h> #include <unordered_map> using namespace std; typedef long long ll; typedef unsigned long long ull; #ifdef LOCAL #define debug(x) cout << "[" __FUNCTION__ ": " #x " = " << (x) << "]\n" #define TIME cout << "RuningTime: " << clock() << "ms\n", 0 #else #define TIME 0 #endif #define hash_ 1000000009 #define Continue(x) { x; continue; } #define Break(x) { x; break; } const int mod = 998244353; const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; #define gc p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; inline int read(){ static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = gc; register bool sgn = false; while (ch != '-' && (ch < '0' || ch > '9')) ch = gc; if (ch == '-') sgn = true, ch = gc; while (ch >= '0'&& ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc; return sgn ? -x : x; } ll fpow(ll a, int b, int mod) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int main() { #ifdef LOCAL freopen("E:/input.txt", "r", stdin); #endif int kcase = 0; int t; cin >> t; while (t--) { int x, L, R; cin >> L >> R >> x; L = x - L; R = R - x; int flag = 0; if (L == R) ; else if (L == 0 || R == 0) flag = 1; else if (L != R) flag = 1; printf("Case #%d: %s\n", ++kcase, flag ? "Alice" : "Bob"); } return TIME; }