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. linux杂记(七)linux档案与目录管理指令

    1.目录的相关操作:cd,pwd,mkdir,rmdir 路径(PATH): 绝对路径:路径的写法[一定由根目录/写起],例如/usr/share/doc这个目录 相对路径:路径的写法[不是由/写起] ...

  2. 原生js写的一个当前年份日期星期和时间的显示

    话不多说,所有代码如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type& ...

  3. PHP查询MYSQL表的主键

    $sql = "SELECT * from Person"; $result = mysql_query($sql,$con); while ($property = mysql_ ...

  4. 【LeetCode题意分析&解答】38. Count and Say

    The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...

  5. Oracle SQL CPU占用高

    Oracle数据库经常会遇到CPU利用率很高的情况,这种时候大都是数据库中存在着严重性能低下的SQL语句,这种SQL语句大大的消耗了CPU资源,导致整个系统性能低下.当然,引起严重性能低下的SQL语句 ...

  6. delphi datasnap 心跳包

    为了能让我们的服务程序更加稳定,有些细节问题必须解决.就如上一讲中提到的客户端拔掉网线,造成服务器上TCP变成死连接,如果死连接数量过多,对服务器能长期稳定运行是一个巨大的威胁.另外,经过测试,如果服 ...

  7. Windows Latex 中日文字体设置例

    中文字体例: \documentclass[CJK]{article} \usepackage{CJKutf8} \newcommand{\songti}{\CJKfamily{song}} % 宋体 ...

  8. Android常用控件之ExpandableList的使用

    先来看下什么是ExpandableListView 跟列表有点像,这种是可以折叠的列表,下面来看下是如何在代码中实现 一.在布局文件中声明一个ExpandableListView <Linear ...

  9. linux下emacs安装

    1.下载地址:http://ftp.gnu.org/pub/gnu/emacs/ 下载文件:emacs-24.2.tar.gz 步骤: 一.安装依赖文件:  (先进入root:终端中输入 su -) ...

  10. SSIS DB目录设置 (Integration Services Catalogs)

    1.创建SSISDB目录 这里没什么好说的,点击Enable CLR Integration ,然后设置一个加密密码 2. SSIS Catalog设置 Retention Period (days) ...