您的位置:首页 > 其它

lightoj 1192 - Left Right Nim博弈

2016-04-13 20:30 302 查看
给定n对点,每一对点中第一个点向右走,第二个点向左右,不能跨越...谁不能走谁输...问最后谁赢。

把一对点的可以走的距离当成石子数量,就变为NIM博弈了..

同上一个题目

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000007
#define inf 0x3f3f3f3f
#define N 100100
int main()
{
int t;
scanf("%d",&t);
for(int cas=1;cas<=t;cas++)
{
int n;
scanf("%d",&n);
int a,b,ans=0;
for(int i=1;i<=n;i++)
{
scanf("%d %d",&a,&b);
ans=ans^(b-a-1);
}
if(ans)
printf("Case %d: Alice\n",cas);
else
printf("Case %d: Bob\n",cas);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: