HDU 1849 —— Rabbit and Grass

    xiaoxiao2021-12-14  19

    原题:http://acm.hdu.edu.cn/showproblem.php?pid=1849

    思路:以两个棋子为例,如果当前它们在不同的位置,那么先手只需要将两个棋子变成在同一个位置,就能获胜,与Nim博弈类似;

    #include<iostream> using namespace std; int m; int main(){ while(cin>>m){ if(m == 0) break; int x = 0; while(m--){ int y; cin>>y; x = x^y; } if(x == 0) cout<<"Grass Win!"<<endl; else cout<<"Rabbit Win!"<<endl; } return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-962984.html

    最新回复(0)