ACM第六届山东省赛 C-Game

ACM第六届山东省赛 C-Game

Time Limit: 2000 ms   Memory Limit: 65536 KiB

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.

Sample Input
2
1
2

Sample Output
zbybr
zbybr

题目链接:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3560.html

本题是一道环形博弈的题目
环形博弈是一个很简单的博弈,n个石子围成一个环,每次取一个或者取相邻的2个,若石子数小于等于2则先手赢,否则后手赢。

参考代码

#include 
int main(void)
{
    long long t, n;
    int i, j, k;
    scanf("%lld", &t);
    while(t--){
        scanf("%lld", &n);
        if(n <= 2)
            printf("zbybr\n");
        else
            printf("blankcqk\n");
    }
    return 0;
}

你可能感兴趣的:(#,第六届山东省赛)