Nyoj 23. Take the stone (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.