poj 2234 题解(英文)

/**
 * 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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值