题意:给定n堆石子,每次能在一堆取1到多个,取到最后一个赢,问谁赢
思路:就裸的的Nim游戏,利用定理求解
代码:
#include <stdio.h> #include <string.h> int n, num; int main() { while (~scanf("%d", &n) && n) { int sum = 0; for (int i = 0; i < n; i++){ scanf("%d", &num); sum ^= num; } printf("%s\n", sum == 0?"No":"Yes"); } return 0; }
10165 - Stone Game(Nim游戏),布布扣,bubuko.com
原文地址:http://blog.csdn.net/accelerator_/article/details/37882721