hdu 4642 Fliping game(博弈)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4642

题意:给定一个棋盘,0表示向下,1表示向上,选一个x,y, 然后翻转从x,y 到n,m.的所有硬币, 谁先把所有硬币翻到0,谁就赢了

题解:不是很好想,主要看最后一个 是否是1, 是1 的话 就是第一个翻的赢了。

因为 你要想赢必须保证你翻完后最后一个方格是0;否则你就输了

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<stack>
 6 #include<queue>
 7 #include<iomanip>
 8 #include<cmath>
 9 #include<algorithm>
10 #include<map>
11 using namespace std;
12 
13 int G[150][150];
14 int main()
15 {
16     int t,n,m,i,j;
17     scanf("%d",&t);
18     while(t--)
19     {
20         scanf("%d%d",&n,&m);
21         for(i=1; i<=n; i++)
22             for(j=1; j<=m; j++)
23             {
24                 scanf("%d",&G[i][j]);
25             }
26         if(G[n][m]) printf("Alice
");
27         else printf("Bob
");
28     }
29     return 0;
30 }
原文地址:https://www.cnblogs.com/bfshm/p/3249823.html