WHU1604 Play Apple 简单博弈

题意:两人分苹果,两种操作:(1)第一个人把苹果分成不相等的两堆
(2)第二个人挑一堆留下,下轮继续玩。 当某个人不能操作的时候,他就输了。 问你如果两个人都采用最优策略,第一个人是否会赢。
思路:NP打表发现规律
#include<bits/stdc++.h>
#define N 45000
#define mes(x) memset(x, 0, sizeof(x));
#define ll __int64
const long long mod = 1e9+7;
const int MAX = 0x7ffffff;
using namespace std;
int dir[560], NP[560];
void f()
{
    int i, n, j;
    NP[1] = 0;
    printf("%d ", 0);
    for(n=2;n<50;n++){
        mes(dir);
        for(i=1;2*i<n;i++){
            if(NP[i] == 0&&NP[n-i] == 0){
                NP[n] = 1;
                break;
            }
        }
        if(2*i >= n) NP[n] = 0;
        printf("%d ", NP[n]);
    }
}
int main()
{
    int n;
    //f();
    while(~scanf("%d", &n)){
        if(n == 2) printf("No
");
        else if(n%3 == 2||n%3 == 0)
            printf("Yes
");
        else printf("No
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/Noevon/p/5385016.html