1722 stone Game 2

Source: Internet
Author: User

Description

When I was on the machine last time, someone asked me, who is tt? Now I want to tell you that I haven't thought about it, so let's continue to call him TT.

In other words, TT is tired of the last stone game. This time, their game rules are as follows:

Two people take stones in turn, with a maximum of p and q each time. The number of remaining stones cannot be obtained (<p, p> = 1. Now the number of stones is N. If TT is used first, will he win? (TT and his roommates are both very smart)

Input

Input t + 1 line

Row 1st is an integer T, indicating that there are T groups of data below.

Row 2-T + 1, with three integers n, p, q in each row

Output

Output a row for each group of data. Determine whether or not TT will win as required.

The difference between this question and the previous question is that there are at most the minimum limit, and the final judgment criterion is that the person cannot get p at the end, the same as the above question at most and the sum, use the remainder of N and P + q for determination.


# Include <iostream> using namespace STD; int main () {int t; int N, P, Q; CIN> T; For (INT I = 0; I <t; I ++) {CIN> N> P> q; If (n <p) {cout <"lose" <Endl ;} else {If (N % (p + q)> = P) cout <"win" <Endl; elsecout <"lose" <Endl ;}} return 0 ;}

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.