Stone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1136    Accepted Submission(s): 792

Problem Description
Tang and Jiang are good friends. To decide whose treat it is for dinner, they are playing a game. Specifically, Tang and Jiang will alternatively write numbers (integers) on a white board. Tang writes first, then Jiang, then again Tang, etc... Moreover, assuming that the number written in the previous round is X, the next person who plays should write a number Y such that 1 <= Y - X <= k. The person who writes a number no smaller than N first will lose the game. Note that in the first round, Tang can write a number only within range [1, k] (both inclusive). You can assume that Tang and Jiang will always be playing optimally, as they are both very smart students.
 
Input
There are multiple test cases. For each test case, there will be one line of input having two integers N (0 < N <= 10^8) and k (0 < k <= 100). Input terminates when both N and k are zero.
 
Output
For each case, print the winner's name in a single line.
 
Sample Input
1 1 30 3 10 2 0 0
 
Sample Output
Jiang Tang Jiang
 
Source
 
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  5503 5502 5501 5500 5499
 

Statistic | Submit | Discuss | Note亚洲赛网络赛水题

#include<stdio.h>
int n,k;
int main(){
while(scanf("%d%d",&n,&k)!=EOF){
if(n==&&k==)
break;
int temp=(n-)%(k+);
if(temp>)
printf("Tang\n");
else
printf("Jiang\n");
}
return ;
}

hdu 4764 巴什博弈的更多相关文章

  1. HDU 4764 Stone(博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 题目大意:Tang和Jiang玩石子游戏,给定n个石子,每次取[1,k]个石子,最先取完的人失败 ...

  2. hdu 1849(巴什博弈)

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

  3. hdu 1846(巴什博弈)

    Brave Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  4. hdu 2897 巴什博弈变形 ***

    大意:一堆石子共有n个,A,B两人轮流从中取,每次取的石子数必须在[p,q]区间内,若剩下的石子数少于p个,当前取者必须全部取完.最后取石子的人输.给出n,p,q,问先取者是否有必胜策略? Bash博 ...

  5. HDU - 1847 巴什博弈

    思路:    0  1  2  3  4  5  6  7  8  9 10 11 12    P N  N P  N N  P N N  P N   N   P 不难发现:当n为三的倍数时,KIKI ...

  6. hdu 2147(巴什博弈+NP图)

    kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total ...

  7. Hdu 2147 巴什博弈 PN图

    P:先手必输   N:先手必胜 PN图规则:如果一个点能转换到的所有点都是N,那么此点状态为P.若能转化到一个P,即使对手面临必输状态,此点为N. 然后找规律就行 #include<bits/s ...

  8. 2013长春网赛 1006 hdu 4764 Stone(巴什博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 题意:Tang 和 Jiang 玩一个游戏,轮流写下一个数,Tang先手,第一次Tang只能写[ ...

  9. hdu 4764 Stone (巴什博弈,披着狼皮的羊,小样,以为换了身皮就不认识啦)

    今天(2013/9/28)长春站,最后一场网络赛! 3~5分钟后有队伍率先发现伪装了的签到题(博弈) 思路: 与取石头的巴什博弈对比 题目要求第一个人取数字在[1,k]间的某数x,后手取x加[1,k] ...

随机推荐

  1. 关于h5中背景音乐的自动播放

    音乐的自动播放属性,这里也介绍一下: <audio controls="controls" autoplay="autoplay"> <sou ...

  2. IE兼容rgba()透明度

    一般浏览器的背景透明度可以直接设置 background:rgba(0,0,0,.5); -webkit-background:rgba(0,0,0,.5); -o-background:rgba(0 ...

  3. Objective-C Operators and Expressions

    What is an Expression? The most basic expression consists of an operator, two operands and an assign ...

  4. uvm_config_db——半个全局变量

    UVM中的配置机制uvm_config_db,uvm_config_db机制用于在UVM平台间传递参数.它们通常是成对出现的,set 寄信,而get函数是收信.config 机制大大提高了UVM的验证 ...

  5. 【数据分析 R语言实战】学习笔记 第八章 方差分析与R实现

    方差分析泛应用于商业.经济.医学.农业等诸多领域的数量分析研究中.例如商业广告宣传方面,广告效果可能会受广告式.地区规模.播放时段.播放频率等多个因素的影响,通过方差分析研究众多因素中,哪些是主要的以 ...

  6. python-mysql软件下载地址

    http://sourceforge.net/projects/mysql-python/?source=dlp

  7. IOSAutolayout

    21:55:33前言 1 MagicNumber -> autoresizingMask -> autolayout 以上是纯手写代码所经历的关于页面布局的三个时期 在iphone1-ip ...

  8. 【Web应用】JAVA网络上传大文件报500错误

    问题描述 当通过 JAVA 网站上传大文件,会报 500 错误. 问题分析 因为 Azure 的 Java 网站都是基于 IIS 转发的,所以我们需要关注 IIS 的文件上传限制以及 requestT ...

  9. jmeter动态参数传值配置

    jmeter动态参数传值配置

  10. Django之CSRF问题

    1.csrf全称:cross site request forgery(跨站请求伪造),举例来讲,一个安全的网站A,一个恶意网站B,当你在A网站进行了登录后,这时候浏览器会保存你的cookie和ses ...