hdu4764 Stone 巴什博弈
来源:互联网 发布:青岛java培训学校 编辑:程序博客网 时间:2024/04/30 10:37
Stone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1439 Accepted Submission(s): 1014
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 130 310 20 0
Sample Output
JiangTangJiang
最后肯定剩一个给对方,谁拿谁输,对N - 1进行巴什博弈,谁先拿完前N - 1也就是剩一个给对方,谁就赢
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int n, k;int main(){while (~scanf("%d%d", &n, &k) && (n || k)) {n -= 1;if (n % (k + 1) != 0) {puts("Tang");} else {puts("Jiang");}}return 0;}
0 0
- hdu4764 Stone 巴什博弈
- hdu4764 Stone 巴什博弈
- hdu4764 Stone (巴士博弈)
- HDU4764 Stone 简单博弈
- hdu4764 Stone
- hdu4764 博弈
- HDU4764 Stone 巴什博奕|签到
- HDU4764 Stone (巴什博奕)
- hdu 4764(stone) 巴什博弈
- HDU 4764 Stone (巴什博弈)
- HDU 4764 Stone (巴什博弈变形)
- hdu 4764 Stone(巴什博弈)
- HDU 4764 Stone 巴什博弈
- HDU-4764-Stone 【巴什博弈】
- HDOJ 4764 - Stone 巴什博弈模板题...
- HDU 4764 Stone(巴什博弈变形)
- HDU 4764(Stone) 巴什博弈变形 Java
- Stone(博弈)
- 软件评测师——计算机网络2
- Android新手入门思维导图
- Python 进阶_OOP 面向对象编程_类和继承
- 拷贝构造函数/重载赋值运算符
- Linux中find常见用法示例
- hdu4764 Stone 巴什博弈
- Integer to Roman
- 新手报到。
- Java中的观察者模式(Observer Pattern)学习
- eclipse构建maven project 的web项目,不勾选Create a simple project 。 < =2= >
- String.format()用法
- linux中一切皆文件, 一切文件皆二进制
- ajax无法跨域调用接口
- 解决了中文乱码的http的get和post请求demo