poj-1740 A New Stone Game 博弈論

題目來源:http://poj.org/problem?id=1740

剛剛看完博弈論的幾篇文章,找了這水題,根據論文裏面的思路很清楚了

#include <iostream>  //只需要判斷它是不是有N對相等的情況
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
bool f[1005];
int main()
{
    int n;
    while (~scanf("%d", &n))
    {
        if(!n)
          break;
        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;
}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章