hdoj 5591 ZYB's Game 【水题】

来源:互联网 发布:sql server 2008下载 编辑:程序博客网 时间:2024/06/04 18:53

ZYB's Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 20    Accepted Submission(s): 15


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].
 

Input
In the first line there is the number of testcases T.

For each teatcase:

the first line there is one number N.

1T100000,1N10000000
 

Output
For each testcase,print the ans.
 

Sample Input
13
 

Sample Output
1
 


找规律:奇数为1,偶数为0。

AC代码:


#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <set>#include <vector>#define INF 0x3f3f3f#define eps 1e-8#define MAXN (100+10)#define MAXM (100000)#define Ri(a) scanf("%d", &a)#define Rl(a) scanf("%lld", &a)#define Rf(a) scanf("%lf", &a)#define Rs(a) scanf("%s", a)#define Pi(a) printf("%d\n", (a))#define Pf(a) printf("%.2lf\n", (a))#define Pl(a) printf("%lld\n", (a))#define Ps(a) printf("%s\n", (a))#define W(a) while(a--)#define CLR(a, b) memset(a, (b), sizeof(a))#define MOD 1000000007#define LL long long#define lson o<<1, l, mid#define rson o<<1|1, mid+1, r#define ll o<<1#define rr o<<1|1using namespace std;int main(){    int t; Ri(t);    W(t)    {        int n; Ri(n);        if(n & 1)            printf("1\n");        else            printf("0\n");    }    return 0;}


0 0
原创粉丝点击