链接:http://acm.hdu.edu.cn/showproblem.php?pid=5591
Problem Description
ZYB played a game named NumberBomb with his classmates in hiking:a host keeps a number in [1,N] in mind,then players guess a number in turns,the player who exactly guesses X loses,or the host will tell all the players that the number now is bigger or smaller than X.After that,the range players can guess will decrease.The range is [1,N] at first,each player should guess in the legal range.
Now if only two players are play the game,and both of two players know the X,if two persons all use the best strategy,and the first player guesses first.You are asked to find the number of X that the second player will win when X is in [1,N].
Now if only two players are play the game,and both of two players know the X,if two persons all use the best strategy,and the first player guesses first.You are asked to find the number of X that the second player will win when X is in [1,N].
Input
In the first line there is the number of testcases T.
For each teatcase:
the first line there is one number N.
1≤T≤100000,1≤N≤10000000
For each teatcase:
the first line there is one number N.
1≤T≤100000,1≤N≤10000000
Output
For each testcase,print the ans.
Sample Input
1
3
Sample Output
1
博弈:当n=1时肯定第二个人赢。当n>=2时,x=1或x=n是肯定第一个人赢。对与其它情况,如果能取的数关于x对称,那么必定第二个人赢,因为不管第一个人取什么数,第二个人都取它对称的数,最后不定第一个人取x。所以当n为偶数时,不管x在什么位置,都是第一个人赢,因为开始所有数不关于x对称,第一人取数后就能让剩下的数关于x对称。当x为奇数时,x只有在中间位置才能第二个人赢,其它位置和偶数情款一样的。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 int t,n; 7 scanf("%d",&t); 8 while (t--){ 9 scanf("%d",&n); 10 if (n%2==1) printf("1 "); 11 else printf("0 "); 12 } 13 }