您的位置:首页 > 编程语言 > C语言/C++

HDU 博弈 1846+1847+1849

2016-11-19 20:56 204 查看
题目链接:
1846:http://acm.split.hdu.edu.cn/showproblem.php?pid=1846
1847:http://acm.split.hdu.edu.cn/showproblem.php?pid=1847
1849:http://acm.split.hdu.edu.cn/showproblem.php?pid=1849
代码如下:
1846:(巴什博弈)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int t;
int a,b;
int flag;
scanf("%d",&t);
while(t--)
{
flag=0;
scanf("%d%d",&a,&b);
while(a>=0)
{
if(a<=b && a>0)
flag=1;
a=a-b-1;
}
if(flag)
printf("first\n");
else
printf("second\n");
}
return 0;
}


1847 :
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int t;
while(~scanf("%d",&t))
{
if(t%3==0)
{
printf("Cici\n");
}
else
{
printf("Kiki\n");
}
}
return 0;
}


1849 :(尼姆博弈)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int t;
int sum=0;
int a[1005];
while(scanf("%d",&t),t)
{
memset(a,0,sizeof(a));sum=0;
for(int i=0;i<t;i++)
{
scanf("%d",&a[i]);
sum^=a[i];
}
if(sum)
printf("Rabbit Win!\n");
else
printf("Grass Win!\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  算法 c语言 函数