poj1704

题目意思:给定若干个棋子的位置,每次可以向左移动一个棋子几个位置,最终无法移动者输。。

思路:博弈论题目。。

       第一次做到这种题目,没什么思路。。参考这位大   神http://www.cnblogs.com/rainydays/archive/2011/09/29/2195649.html

 1 #include <iostream>
 2 #include <cstdlib>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 using namespace std;
 7 int a[10001] , n ,test;
 8 
 9 int main(){
10     scanf("%d",&test);
11     while (test --){
12            scanf("%d",&n);
13            a[0] = 0;
14            for (int i = 1; i <= n; ++i)
15               scanf("%d",&a[i]);
16            sort(a, a + 1  + n );
17            int ans = 0;
18            for (int i = n; i > 0; i -= 2)
19            ans ^=(a[i] - a[i - 1] - 1);
20            if (ans == 0)  printf("Bob will win\n");
21                  else printf("Georgia will win\n");
22    }
23 }
原文地址:https://www.cnblogs.com/yzcstc/p/2977873.html