hdu5591(博弈)

来源:互联网 发布:微创软件怎么样 编辑:程序博客网 时间:2024/06/03 14:14

ZYB’s Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 632 Accepted Submission(s): 510

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.

1≤T≤100000,1≤N≤10000000

Output
For each testcase,print the ans.

Sample Input

1
3

Sample Output

1

这道题,很简单,只要模仿对方就可以了,只有奇数的时候,后手永远模仿先手,所以先手没法赢。

#include<bits/stdc++.h>int main(){    int n,T;    scanf("%d",&T);    while(T--){        scanf("%d",&n);        if(n&1)printf("1\n");        else puts("0");    }    return 0;}
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 贴膜白边去除液漏进屏幕里面怎么办 魅族pro6s电池休眠了怎么办 京东预约错了怎么办 魅蓝手机声音小怎么办 魅族2手机锁定了怎么办 flyme的密码忘了怎么办 魅族note3忘记开机密码怎么办 小米3s手机死机怎么办 二手小米手机有账号锁怎么办 小米五指纹解锁失灵怎么办 小米note3指纹解锁失灵怎么办 小米4s手机屏幕失灵怎么办 vivo手机没有otg功能怎么办 头戴耳机压头发怎么办 小米4c很卡怎么办 小米4c玩王者怎么办 小米4s屏幕乱跳怎么办 小米4s手机后壳碎了怎么办 小米5spius开不了机怎么办 小米5s无限重启怎么办 小米5s外屏坏了怎么办 小米5s内屏碎了怎么办 小米4充电没反应怎么办 小米5手机变卡了怎么办 小米5变卡了怎么办 小米手机充电无反应怎么办 小米6相机卡顿怎么办 华为手机玩游戏发热怎么办 华为手机变慢了怎么办 华为p10手机变慢怎么办 华为手机账户密码忘记了怎么办 QQ浏览器无法加载插件怎么办 电脑开了机黑屏怎么办 扫描仪打不开运单扫描怎么办 打印机不支持64位系统怎么办 xp系统dnf闪退怎么办 w10电脑所有程序都打不开怎么办 安卓手机太卡怎么办 系统装到f盘了怎么办 虚拟机占c盘内存怎么办 外机连无线虚拟机显示受限怎么办