牛客国庆集训派对Day3 G Stones

Stones

思路:

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;
}

 

转载于:https://www.cnblogs.com/widsom/p/9741732.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值