Take Stone (a) time limit:MS | Memory limit:65535 KB Difficulty:2
-
Describe
-
one day, TT in the dorm idle bored, and the people who play with the bed to take the stone game, and because of limited conditions, he/they are using Mong Tsai small steamed bread as a stone. The rules of the game are like this. With a heap of stones, the number of N (1<=n<=1000000), two people take turns to remove several of them, each time up to M (1<=m<=1000000), the first to take the stone to victory. We know that TT and his/her roommates are very smart, so if it's TT first, will he/she win the game?
-
-
Input
-
-
The first line is a positive integer n means there are n sets of test data
Input has less than 1000 sets of data, one row per group of data, two numbers n and M, separated by a space.
-
-
Output
-
-
for each set of data, output one line. If the first pick of the TT can win the game, then output "win", otherwise output "lose" (quotes without output)
-
-
Sample input
-
-
21000 11 100
-
-
Sample output
-
Losewin
Math problem:
Inverse push, if the last time TT (set to K) the Pebble is less than or equal to M, then the TT can win, then the first k-1 must be m+1, in order to make the K-th must be less than or equal to M.
Because TT takes first, can get N% (m+1)! =0 is TT wins.
1#include <iostream>2 using namespacestd;3 intMain ()4 {5 intM,n,n;6Cin>>N;7 while(n--)8 {9Cin>>n>>m;Ten if(n% (m+1)) Onecout<<"Win"<<Endl; A Else -cout<<"lose"<<Endl; - } the return 0; -}
Nyoj 23. Take the stone (i)