// UVa Problem 10165 - Stone Game
// Verdict: Accepted
// Submission Date: 2011-11-17
// UVa Run Time: 0.020s
//
// 版权所有(C)2011,邱秋。metaphysis # yeah dot net
//
// [解题方法]
// 啊哈,很有趣的一个题目。在网络上搜索一下 Nim 和 Xor,就可以了解到相关信息。若是自己想,一年也
// 想不出来吧。
#include <iostream>
using namespace std;
int main (int argc, char const* argv[])
{
int piles, stones, tmpStones;
while (cin >> piles, piles)
{
stones = 0;
for (int i = 1; i <= piles; i++)
{
cin >> tmpStones;
stones ^= tmpStones;
}
cout << (stones ? "Yes" : "No") << endl;
}
return 0;
}
UVa Problem 10165 - Stone Game
最新推荐文章于 2019-02-10 16:55:19 发布
本文介绍了UVa在线评测系统中编号为10165的Stone Game问题的解决方法。该题可通过计算多个石堆状态的Nim和来判断先手是否有必胜策略。文章提供了AC代码示例,并使用了XOR操作符实现简洁高效的算法。
1583

被折叠的 条评论
为什么被折叠?



