POJ1740

简介:

这题想了好久都没想出来 然后在网上搜的题解 终于明白了。。。 

当为1堆的时候 先手为必胜态 

当为2堆并且两堆都相同时 先手怎么走后手怎么走就行了

当为3堆 先手只要一次拿成两堆且相同 的情况就是必胜态

4堆的时候只要看排序后 两堆 两堆是否相同就行了 

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

bool f[1005];

int main()
{
    int n;
    while (scanf("%d", &n)&& n)
    {
        memset(f, 0, sizeof(f));
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            int a;
            scanf("%d", &a);
            if (f[a])
                ans--;
            else
                ans++;
            f[a] = !f[a];
        }
        if (ans)
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}


目录
打赏
0
0
0
0
1
分享
相关文章
poj 2503 查字典
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language.
886 0
POJ 2262 Goldbach&#39;s Conjecture
Problem Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the foll...
1035 0