POJ

https://vjudge.net/problem/POJ-2315

#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
const double PI = acos(-1.0);

//模板部分
const int MAXN = 50;
int SG[MAXN];//需要处理的SG值数组
int XOR[MAXN];//储存每一个二进制位上的和
int xxx;//储存每一个SG值的临时变量
int num;//储存当前SG值有多少位的临时变量
int maxn;//储存最大的SG值位数

bool solve(int N, int M)//N表示SG数组的大小,从1到N,M表示每次可以取1到M堆
{
    memset(XOR, 0, sizeof XOR);
    maxn = -1;
    for (int i = 1; i <= N; i++) {
        xxx = SG[i];
        num = 0;
        while (xxx) {
            XOR[num] += xxx & 1;
            num++;
            xxx >>= 1;
        }
        maxn = max(maxn, num);
    }
    for (int i = 0; i < maxn; i++)
        if (XOR[i] % (M + 1))
            return true;//返回true表示先手必胜
    return false;//返回false表示先手必败
}
//上面模板

int N, M, L, R;
int s;

int main() {
    while (scanf("%d%d%d%d", &N, &M, &L, &R) != EOF) {
        s = L / (2 * PI * R) + 1;//只能射出周长的整数被,并且不能超过L
        for (int i = 1; i <= N; i++) {
            scanf("%d", &SG[i]);
            SG[i] = SG[i] / (2 * PI * R) + 1;
            SG[i] %= s;//NIM游戏每个石子堆的个数
        }
        if (solve(N, M))
            printf("Alice
");
        else
            printf("Bob
");
    }
}

来自大佬的博客,上面部分没怎么看懂,以后慢慢看吧

原文地址:https://www.cnblogs.com/xcfxcf/p/12559574.html