1022: Take stone (a)
Description
One day, TT idle boredom in the bedroom, and lay people playing the game to take stones, but due to limited conditions, he / she is as a stone with Wang Zi small steamed bread. Rules of the game is this. With a pile of stones, as the number N (1 <= N <= 1000000), takes some two turns of which, taking a maximum of M (1 <= M <= 1000000), the first to the pebble finish taker victory. We know, TT and his / her roommate are very clever, so if TT is the first take, he / she will win the game it?
Input
The first line is a positive integer and n represents an n set of test data
is input less than 1,000 sets of data, each data line, there are two numbers N and M, separated by spaces between.
Output
For each data output line. If you take the first TT win the game, the output "Win", otherwise output "Lose" (without the quotation marks output)
Sample Input
2
1000 1
1 100
Sample Out
Lose
Win
Problem-solving ideas
Take the stone problem. It is the evolution of game theory
then. A total of n gravel, a maximum number of m, and takes a minimum.
The first set is taken stone person A, taken after the B
can be seen if n = m + 1 or n = k (m + 1) (k may take any positive integer)
A would lose all
Code
python
while n>0:
l=[int(i) for i in input().split()]
x,y=l[0],l[1]
if x%(y+1)==0:
print('Lose')
else:
print('Win')
n=n-1
reward
Game Bash (Bash Game)
Here quoted a Gangster article.
Game Theory - Take stones issues