Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5591

Description

].

Input

In the first line there is the number of testcases 10000000

Output

For each testcase,print the ans.

Sample Input

1 3

Sample Output

1

HINT

 

题意

 hdu 5591 ZYB's Game 博弈论

题解:

我们会发现这个模型其实是类比于左右两堆石子,每次可以在一堆里取任意多,取完的人胜利.当左右两堆石子相同时,我们可以简单的

构造后手胜利的方法:即在另一堆石子中取走同样多的石子,否则,先手可以取一些石子使得两堆石子相同.所以,当N是奇数输出1,否则输出0.

当然也可以直接sg函数打表,打出来就可以找到规律了

代码:

#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int t;scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int x;scanf("%d",&x);
        printf("%d\n",x&1);
    }
}

 

相关文章: