思路:
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 + ;
int sg[N], s[N];
int x[N];
int SG(int n, int a, int b) {
int m = n%(a+b);
if(m == || m < a) return ;
if(n <= a+b) return ;
m -= (a-);
if(a == ) return m;
else {
if(m <= b-a) return (m+a-)/a + ;
else return ;
}
}
void get_sg(int n, int a, int b) {
mem(sg, );
for (int i = ; i <= n; i++) {
mem(s, );
for (int j = i-b; j <= i-a; j++) {
if(a <= j && j <= b || j < ) continue;
s[sg[j]] = ;
}
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 = ;
bool f = false;
for (int i = ; 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 ;
}