HDU-2897- Ming

Source: Internet
Author: User

Start with the question:

Encounter Mingxia

Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 2474 accepted submission (s): 1141


The Problem description encountered a month on the same day, so it became clear. When I met you, I became a companion.
On that day, the sun and the moon met and I met you. Moreover, if the earth loses its glory, will you and I become friends? This is doomed to be a beautiful story. (The above is nonsense)
Like all secular people, Mr. T looks forward to the rare eclipse of a hundred years. Stop on the street to see the day, see the day and the month approaching, the Little T's neck is sour (he insisted that this posture has been more than half an hour ). He looked up and looked around. Suddenly I found a pretty mm standing around me. Gradually, this mm is so dazzling on this street. Is she an angel? The angel standing around t.
T shouted to mm: "Fate ~~". Mm is unambiguous: "Yes, we met in 500 !" (5000 words later ....)
John asked mm for contact information, but mm said, "I am playing a game with you. If you win, I will tell you my mobile phone number ." T, I thought that there would be a problem in the world that could beat me down, so I agreed. MM started to talk about the game rules: "I have a pile of coins, a total of seven. I have taken coins from this coin heap. I have two or more coins at a time, if there are less than two items left, it will be taken once. I took turns with you until the coins in the heap were taken, and the last coin was counted and lost. I have played this game many times, so let you get it first ~"
T refers to a computation. No, is this an impossible task. Little T smiled proudly: "mm is preferred, haha ~" Mm was stunned at the hour. I thought it was an unexpected response to the small T.
But she is not angry: "Good boy, it's pretty clever. Otherwise, you give me my mailbox and I will send you a text, each line has three numbers N, p, Q, indicates that a pile of coins have a total of n coins. Take the coins from this coin heap. Take at least p coins at a time, and obtain a maximum of Q coins. If there are less than p coins, you need to get them all at once. The two take the coins in turn until the coins in the heap are taken, and the last coin is counted and lost. For the three numbers in each row, whether the first person has a winning strategy is given. If there is a win, otherwise the lost is answered. You can send me the corresponding answer. If you can send me the correct answer before this evening, maybe we can see you tomorrow afternoon ."
T gave his email address to mm. When he is eager to go home and check his mailbox online, wow! MM's email has arrived. He found that the text is up to 100000 rows, and the three numbers in each line are large, but they are all integers up to 65536. It's already six o'clock P.M. In the table. It seems impossible to manually calculate all the results. Can you help him and let him see the MM again?

 

Input cannot exceed 100000 rows. Each row has three positive integers, N, P, and Q.

 

Output corresponds to each line of input. Based on the game rules described above, determine whether the first accessor has a winning strategy. Output win or lost.

 

Sample input7 2 46 2 4

 

The sample outputlostwin is like the complete version of baseline. The basic condition for determining baseline is n % (1 + M )! = 0? First-hand win: second-hand win. Here, we can use a wider range of baybo games. We can specify the lower bound of the child. The condition for determining bashboyi with a lower bound is n % (p + q )! = 0? First-hand win: the latter-hand win. Of course, it cannot be judged here, because the remainder will also affect the outcome. Here, whoever goes to the last time is the loser. First, we can get n = (p + q) * R + S (P <= Q ). If S is smaller than P, it is impossible to take S for the first time, so it is good for the first hand to take (K), as long as the latter hand to take (p + q-K) in the end, s will be left for the first hand, so the first hand will lose. If S> = P, then the first hand only needs to take S for the first time, then the next hand gets K for each time, and the first hand gets p + q-K to win the first hand. So here is the condition for the first-hand victory! (0 <n % (p + q) & N % (p + q) <p ). Code:
 1 #include <iostream> 2 #define min(x,y) (x < y ? x : y) 3 using namespace std; 4  5 int main() 6 { 7     ios::sync_with_stdio(false); 8     int n,p,q; 9     while(cin>>n>>p>>q){10         if(n%(p+q)!=0 && n%(p+q)<=p) cout<<"LOST"<<endl;11         else cout<<"WIN"<<endl;12     }13     return 0;14 }
/X 2897 */

 

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.