John
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 945 Accepted Submission(s): 495
Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.
Constraints:
1 <= T <= 474,
1 <= N <= 47,
1 <= Ai <= 4747
2 3 3 5 1 1 1
John Brother
#include<iostream>
using namespace std;
int main()
{
int T;
cin>>T;
while(T>0)
{
T--;
int n;
cin>>n;
int u,k=0,t;
cin>>t;
if(t>1)k++;
for(int i=1;i<n;i++)
{
cin>>u;
t=t^u;
if(u>1)k++;
}
if(k==0)
{
if(n%2==0)cout<<"John"<<endl;
else cout<<"Brother"<<endl;
}
else
{
if(t!=0)cout<<"John"<<endl;
else cout<<"Brother"<<endl;
}
}
return 0;
}
这个是一个博弈问题,详细情况看我转载的博弈题目总结。。。。
文章探讨了使用博弈论原理解决M&M糖果分配游戏的问题,通过输入不同颜色糖果的数量,预测游戏的最终胜者是John还是他的弟弟。
4951

被折叠的 条评论
为什么被折叠?



