"Hdoj 4764" Stone (game)
StoneTime
limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1090 Accepted Submission (s): 761
Problem Descriptiontang and Jiang are good friends. To decide whose treat it was for dinner, they was playing a game. Specifically, Tang and Jiang would alternatively write numbers (integers) on a white board. Tang writes first, then Jiang, then again Tang, etc ... Moreover, assuming that's the number written in the previous round was X, the next person who plays should write a number Y s Uch that 1 <= y-x <= K. The person who writes a number no smaller than N first would lose the game. Note in the first round, Tang can write a number is only within range [1, K] (both inclusive). You can assume that Tang and Jiang'll always be playing optimally, as they is both very smart students.
Inputthere is multiple test cases. For each test case, there'll be a line of input has a integers n (0 < n <= 10^8) and K (0 < K <= 100) . Input terminates when both N and K is zero.
Outputfor each case, print the winner ' s name.
Sample Input
1 130 310) 20 0
Sample Output
Jiangtangjiang
Write a number game turns out that a number less than n is required to increment and the current player writes a number that is written by the previous player with the difference in value <= K writes n the output of the
Can be converted to take a stone (however, the topic is stone for not too red fruit to adapt the next = = also drunk
So as long as (n-1) for (k+1) a multiple that the can always reach k+1 (k+1) * * (k+1) .... The state so that the initiator will lose the rest of the state can reach n-1
The code is as follows:
#include <bits/stdc++.h>using namespace Std;int main () {int n,m,t,i,j,u,v,w;while (~SCANF ("%d%d", &n,&m) && n+m) {if ((n-1)% (m+1)) puts ("Tang"); else puts ("Jiang");} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Hdoj 4764" Stone (game)