/**
* Created: 2011-8-20
* By: eeorange
* OS: Windows/mingw
* Ques ID: poj 2234 - Maches Game
* Status: Accept
* Simple Idea: How to solve the problem?
Let's think about a simple question. If there are two piles, have n1, n2 matches.
Follow rules according to the problem. Who will win?
The answer is if n1 == n2, person 2 win. else person 1 win.
That the NIM rules. If you don't know please look at the book.
How can we manage if there are many piles?
If there many piles, split each pile into small piles.
eg: 11 = 2^0 + 2^1 + 2^3
A = a1 + a2 + a3 + a4;
B = b1 + b2 + b3 + b4;
C = c1 + c2 + c3 + c4;
if a1^b1^c1 != 0, then piles are not balance. person 1 will win.
*/
#include <iostream>
using namespace std;
int main(){
int n;
while(cin >> n)
{
int s = 0, t;
while(n--){ cin >> t; s ^= t; }
printf("%s\n", s != 0 ? "Yes" : "No");
}
return 0;
}
poj 2234 题解(英文)
最新推荐文章于 2022-06-22 15:04:51 发布