http://acm.hdu.edu.cn/showproblem.php?pid=2176
nim博弈的模型。要输出先手第一次取的情况,考虑角度是留给对手必败态
#include <iostream> #include <cstdio> using namespace std; int a[200005]; int main() { int m; while(~scanf("%d", &m), m) { int s = 0; for(int i = 0; i < m; i++) { scanf("%d", &a[i]); s ^= a[i]; } if(!s) puts("No"); else { puts("Yes"); for(int i = 0; i < m; i++) { int st = s ^ a[i]; if(st < a[i]) printf("%d %d\n", a[i], st); } } } return 0; }