牛客小白月赛7 B 自杀游戏
思路:
sg函数
代码:
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL unsigned long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pii pair<int, int> #define piii pair<pii, int> #define mem(a, b) memset(a, b, sizeof(a)) #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout); //head const int N = 1e5 + 100; int sg[N]; bool vis[100]; vector<int> vc; int main() { int t, a, b; scanf("%d %d %d", &t, &a, &b); vc.pb(1); for (int i = a; i <= b; i++) vc.pb(i+1); for(int i = 1; i <= t; i++) { mem(vis, false); for (int a : vc) { if(a > i) break; vis[sg[i-a]] = true; } for (int j = 0; ; j++) { if(!vis[j]) { sg[i] = j; break; } } } if(sg[t]) puts("Alice"); else puts("Bob"); return 0; }