题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4642
题解思路: 很容易得到,谁先把所有的硬币翻成反面朝上,谁就害得对方没办法继续下去,自己就获胜了,假设进行了K局,使得第一次全部的硬币都反面朝上了。事实上,k在比赛的一开始就确定好了,因为每次操作都会改变最右下角的那个1,0的奇偶性,那么最后一个数一开始是1,k必然是奇数,Alice获胜,一开始是0,k必然是偶数,Bob获胜。 嗯嗯,就这一点巧,感谢ChoiceZ的神YY~
代码:
#include<iostream> #include<cstdio> #include<string> using namespace std; int main() { int T; cin>>T; int n,m; while(T--) { cin>>n>>m; getchar(); string s; for(int i=0;i<n-1;i++) { getline(cin,s); } int temp; for(int i=0;i<m;i++) cin>>temp; if(temp==1) cout<<"Alice"<<endl; else cout<<"Bob"<<endl; } }