HDU 2176 (Nim博弈 先手取胜方案) 取(m堆)石子游戏
切切水题,放松心情:-D
1 #include <cstdio> 2 3 const int maxn = 200000 + 10; 4 int a[maxn]; 5 6 int main() 7 { 8 //freopen("in.txt", "r", stdin); 9 10 int m; 11 while(scanf("%d", &m) == 1 && m) 12 { 13 int s = 0; 14 for(int i = 0; i < m; i++) { scanf("%d", &a[i]); s ^= a[i]; } 15 if(!s) { puts("No"); continue; } 16 puts("Yes"); 17 int k = -1; 18 int t = s; 19 while(s) { s >>= 1; k++; } 20 for(int i = 0; i < m; i++) if(a[i] & (1 << k)) printf("%d %d\n", a[i], a[i] ^ t); 21 } 22 23 return 0; 24 }