POJ1740 A New Stone Game

2015.01.13 09:02 Tue| 4 visits oi_2015| 2015_刷题日常| Text

Solution

真是最好写的一道男人题 -_-||

如果所有的石子都可以两两配对的话,显然后手必胜。否则显然先手可以通过一次操作使得石子可以两两配对,于是先手必胜。

//为什么在 POJ 上面交题至少 CE 一次……

Code

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

inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch-'0'; ch = getchar(); }
    return x * f;
}

int a[15];

int main()
{
    while (int n = read())
    {
        int ans = 0;
        for (int i = 1; i <= n; ++i)
            a[i] = read();
        sort(a + 1, a + n + 1);
        for (int i = 1; i <= n; i += 2)
            if (a[i] != a[i + 1])
                ans = 1;
        printf("%d\n", ans);
    }
}