题目-Nim游戏

题目链接:51Nod—1069 Nim游戏

ac代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#define _MAX 1001

int main()
{
int N, stone, tag = 0;
scanf("%d", &N);
while (N--){
scanf("%d", &stone);
tag ^= stone;
}
//tag为0则为后手赢,否则为先手赢
printf("%c\n", tag == 0 ? 'B' : 'A');
return 0;
}