POJ1704:Georgia and Bob (NIM博弈 类似阶梯博弈)

来源:互联网 发布:欧洲杯决赛数据 编辑:程序博客网 时间:2024/05/16 01:07

#include#include#includeusing namespace std;int main(){int T;int n;int P[1010];cin >> T;while (T--){cin >> n;for (int i = 0; i < n; i++){cin >> P[i];}int x = 0;if (n % 2 == 1) P[n++] = { 0 };//如果是奇数个,加一个数,形成一对sort(P, P + n);for (int i = 0; i + 1 < n; i = i + 2){x ^= (P[i + 1] - P[i]-1);}if (x == 0)puts("Bob will win");else puts("Georgia will win");}return 0;}

原创粉丝点击