10165 - Stone Game(Nim游戏)
UVA 10165 - Stone Game
题意:给定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; }