HDU 3537 Daizhenyang's Coin (经典翻硬币博弈问题)
题意:
一切皆网络流的戴神要追一个妹子。。。额。。算了直接说题意吧。。。不过题目背景真是有意思。。
给你一些正面朝上硬币的位置,其他的位置硬币都是反面朝上的,每一次可以选择一个或者两个或者三个硬币将它们翻转 (正面变反面,反面变正面),但是最右边一个硬币必须是正面的,最后不能操作的人输。
解题思路:
有趣的翻硬币问题。。。可以参考很全的资料,全都是翻硬币游戏!
http://blog.csdn.net/acm_cxlove/article/details/7854534
/* **********************************************Author : JayYeCreated Time: 2013-11-1 18:24:56File Name : JayYe.cpp*********************************************** */#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int maxn = 100 + 5;int a[maxn];int main() { int n; while(scanf("%d", &n) != -1) { for(int i = 0;i < n; i++) scanf("%d", &a[i]); sort(a, a + n); int ans = 0; for(int i = 0;i < n; i++) if(i == 0 || a[i] != a[i-1]) { int x = a[i]*2, cnt = 0; while(x) { if(x&1) cnt++; x >>= 1; } if(cnt&1) ans ^= a[i]*2; else ans ^= a[i]*2 + 1; } if(ans) puts("No"); else puts("Yes"); } return 0;}