F - Stone-----(2015 summer training #11)
来源:互联网 发布:hadoop 数据存储 编辑:程序博客网 时间:2024/04/29 22:14
F - Stone
时限:1000MS 内存:32768KB 64位IO格式:%I64d & %I64u问题描述
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.
输入
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.
输出
For each case, print the winner's name in a single line.
样例输入
1 130 310 20 0
样例输出
JiangTangJiang
分析:经典的博弈问题。首先考虑一下必胜的情况,当变成什么状况时,无论对手怎么做,我都是赢得情况。拿10 2这组数据,当我拿到9时,我就必胜。继续前推,当我拿到6时,我也是必胜。再推,我拿到3时必胜。。。。。。。。。。。。这样就能总结出公式。
CODE:
#include <iostream>using namespace std;int main(){ long long n,k; while(cin>>n>>k&&(n||k)){ if((n-1)%(k+1)==0) cout<<"Jiang"<<endl; else cout<<"Tang"<<endl; } return 0;}
0 0
- F - Stone-----(2015 summer training #11)
- Problem F. Flat----(2015 summer training #5)
- J - Flyer------(2015 summer training #11)
- ecjtu-summer training #5 F
- ecjtu-summer training #6 F
- D - Cut the Cake----(2015 summer training #11)
- E - Theme Section-----(2015 summer training #11)
- ecjtu-summer training #1 F (UVA 11461)
- ecjtu-summer training #3 F HDU 1312 Red and Black
- C - We Love MOE Girls---(2015 summer training #9)
- B - And Or---(2015 NEUQ_ACM summer training #1)
- A - Faulty Odometer---(2015 summer training #3)
- H - Load Balancing---(2015 NEUQ_ACM summer training #1)
- J - Intelligent IME---(2015 summer training #3)
- C - Colorful Rainbows----(2015 summer training #4 (Qualifying))
- K - Kinds of Fuwas----(2015 summer training #4 (Qualifying))
- Problem A. Automated Telephone Exchange----(2015 summer training #5)
- B - Median-----(2015 summer training #8(Qualifying))
- CSDN公开课:SCRUM敏捷开发(2015-8-19 免费)
- 一张图看明白android 接口回调机制
- HDU4300-Clairewd’s message-KMP
- SQL用法大全
- mysql导入导出数据的好方法
- F - Stone-----(2015 summer training #11)
- MySQL在Win2008下如何设置双主热备
- C++的struct和union
- PHP数据类型转换的一些坑
- 关于Beta分布、二项分布与Dirichlet分布、多项分布的关系
- ACdream1007 a+b 快速幂求和
- 九度oj 1029
- Codeforces 570 D. Tree Requests
- 互联网电商大数据环境 ——大数飓数据分析实践培训精华笔记(八)——电商核心业务知识之订单商品模块三