15年山东第六届acm省赛 C题 Game!(博弈)

本文介绍了一种基于博弈论的游戏,玩家轮流从一圈石头中取走一个或两个相邻的石头,探讨了最优策略下胜者归属的问题。通过分析游戏规则,得出结论:当初始石头数量为1或2时,先手玩家获胜;否则后手玩家获胜。

Game!

Time Limit: 1000MS  Memory Limit: 65536KB
Problem Description

One day, zbybr is playing a game with blankcqk, here are the rules of the game:

There is a circle of N stones, zbybr and blankcqk take turns taking the stones.

Each time, one player can choose to take one stone or take two adjacent stones.

You should notice that if there are 4 stones, and zbybr takes the 2nd, the 1st and 3rd stones are still not adjacent.

The winner is the one who takes the last stone.

Now, the game begins and zbybr moves first.

 

If both of them will play with the best strategy, can you tell me who will win the game?

Input

The first line of input contains an integer T, indicating the number of test cases (T≈100000).

For each case, there is a positive integer N (N ≤ 10^18).

Output

Output the name of the winner.

Example Input
2
1
2
Example Output
zbybr
zbybr
分析:博弈题,难推易实现,成环的两个之间被拿走一个,不是相邻的,所以长度为n的拿走后有两种状态:长度为n-1的链子合或是长度为n-2的链子;

代码如下:

#include<stdio.h>

int main()
{
	int a,t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&a);
		if(a==1 ||a==2)
		{
			printf("zbybr\n");
		}
		else
		{
			printf("blankcqk\n");
		}
	}
	return 0;
}




评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值