思路:
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 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, pii> #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 = 1e3 + 100; int sg[N], s[N]; int x[N]; int SG(int n, int a, int b) { int m = n%(a+b); if(m == 0 || m < a) return 0; if(n <= a+b) return 1; m -= (a-1); if(a == 1) return m; else { if(m <= b-a) return (m+a-1)/a + 1; else return 1; } } void get_sg(int n, int a, int b) { mem(sg, 0); for (int i = 1; i <= n; i++) { mem(s, 0); for (int j = i-b; j <= i-a; j++) { if(a <= j && j <= b || j < 0) continue; s[sg[j]] = 1; } while(s[sg[i]]) sg[i]++; // cout << i << " " << sg[i] << " " << SG(i, a, b) << endl; } } int main() { int n, a, b, T; scanf("%d", &T); while(T--) { scanf("%d %d %d", &n, &a, &b); // get_sg(n, a, b); int ans = 0; bool f = false; for (int i = 1; i <= n; i++) { scanf("%d", &x[i]); ans ^= SG(x[i], a, b); if(a <= x[i] && x[i] <= b) f = true; } if(f || ans) puts("Yes"); else puts("No"); } return 0; }