ZYB's Game

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

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
 题意:一个游戏,让你在一定范围内猜数X,起始范围是【1,N】随着猜,裁判会告诉你大了还是小了,范围会逐渐减小;
假设猜之前两个人都知道了这个数X,谁猜到,谁就输了,给你一个N让求有多少个X会让后者赢;
方法:要想让第二个人赢,第二个人走的最优方法是第一个人每走一个点,第二个人要走关于x对称的点,所以只有N是奇数的时候,第二个人才会赢,而赢的点就是(1+N)/2;
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
int main(){
int x,T;
scanf("%d",&T);
while(T--){
scanf("%d",&x);
if(x&1)puts("1");
else puts("0");
}
return 0;
}

  

ZYB's Game(博弈)的更多相关文章

  1. HDU - 5591 ZYB's Game(博弈)

    题意:A和B两人在1~N中选数字.已知1<=X<=N,谁先选中X谁就输.每当一个人选出一个不是X的数,裁判都会说明这个数比X大还是小,与此同时,可选范围随之缩小.已知A先选,求满足能让B赢 ...

  2. BestCoder Round #65 hdu5591(尼姆博弈)

    ZYB's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. hdu----(1849)Rabbit and Grass(简单的尼姆博弈)

    Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDU 5754 Life Winner Bo 组合博弈

    Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard gam ...

  5. 线段树 - ZYB's Premutation

    ZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutation,now he ...

  6. HDU 2509 Nim博弈变形

    1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

  7. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

  8. 51nod1072(wythoff 博弈)

    题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1072 题意: 中文题诶~ 思路: 博弈套路是有的, 找np局 ...

  9. ACM: NBUT 1107 盒子游戏 - 简单博弈

     NBUT 1107  盒子游戏 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

随机推荐

  1. mysql 调用存储过程及例子

    存储过程如同一门程序设计语言,同样包含了数据类型.流程控制.输入和输出和它自己的函数库. --------------------基本语法-------------------- 一.创建存储过程 c ...

  2. IE7.JS解决IE兼容性问题方法

    转自:http://code.google.com/p/ie7-js/ 使IE5,IE6兼容到IE7模式(推荐) <!--[if lt IE 7]> <script src=&quo ...

  3. Android WindowManager 小结

    Android---系统服务之 ---WindowManager WindowManager是Android中一个重要的服务(Service ).WindowManager Service 是全局的, ...

  4. qcow2、raw、vmdk等镜像格式

    转自 http://www.prajnagarden.com/?p=248 http://blog.csdn.net/starshine/article/details/8179483 转者言:对pr ...

  5. Qt双缓冲机制:实现一个简单的绘图工具(纯代码实现)

    http://blog.csdn.net/rl529014/article/details/51658350

  6. Javascript 思维导图

    学习的道路就是要不断的总结归纳,好记性不如烂笔头,so,下面将po出8张javascript相关的思维导图. 思维导图小tips:思维导图又叫心智图,是表达发射性思维的有效的图形思维工具 ,它简单却又 ...

  7. HDU 5768 Lucky7(CRT+容斥原理)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5768 [题目大意] 求出一个区间内7的倍数中,对于每个ai取模不等于bi的数的个数. [题解] 首 ...

  8. STL-multimap

    转自:http://www.cnblogs.com/xiaoka/archive/2011/08/09/2132342.html multimap提供了可以一种可以有重复键值的STL map类型.其插 ...

  9. 系统变量写在.bash_profile和.bashrc的区别

    今天配置一个代理,正儿八经的把我搞蒙了,不就是export http_porxy=xxx.xxx.xxx.xxx:xxxx 然后重启服务service network restart ,依然连接不了外 ...

  10. UVa1368/ZOJ3132 DNA Consensus String

    #include <stdio.h>#include <string.h> int main(){    int a[4][1000]; // A/C/G/T在每列中出现的次数 ...