E-Nana in Wonderland Series--inexplicable episode
E-Nana in Wonderland Series--inexplicable episodeTime Limit:2000/1000ms (java/others) Memory Limit: 128000/64000kb (java/others) Problem Description
Nana because to help peach blossom villagers solve a big problem and by the villagers respect, but because Nana still want to continue to explore this magical world, had to reluctantly and villagers farewell. When Nana left the village, Nana lost her memory! She did not remember all the peach Blossom Village, she did not remember to eat a lot of sweets, she did not remember her to go to the lake and jump for a long while, even her own name do not remember! Nana wandered blindly around, suddenly came to a Prince Charming, he asked: "Are you Alice?" ”。 Nana thought, "Alice?" Well-cooked name, is this my name? "and answered:" Yes. May I ask what you are? "Prince Charming is happy to say:" My name is Bob, I find you for a lifetime, without you, I am always forgotten by the father, we go back to the palace! The Yu Shinana was taken to the palace in a daze.
King: "Are you Alice?" What do you think? 3rd, you become dementia, ah, you and my son Bob first play a game, I see if you have a brain problem. Nana had to play the game with Bob in order to prove her mind was fine.
The rules of the game are very simple, there is a collection at the beginning, there are n different numbers in the collection, and Alice (Nana) and Bob take turns to operate, each can choose two number A, B, may wish to set a>b, but requires a-a not in the collection, a-B into the collection. If it's someone's turn and can't do anything, the person loses the game. As a professional game player, Nana can use the body's intuition to carry out optimal operation even if she loses her memory. Then ask, when Alice (Nana) and Bob all along the optimal strategy, the woman first (that is, Nana), who will win in the end?
Input
Multiple sets of data, first a positive integer t (t<=20), representing the number of groups of data
For each set of data, the first is an integer n (1<=n<=1,000), followed by n integers x[i] (0<x[i]<=1,000,000,000), which represents the collection. Ensure that the collection elements do not appear the same.
Output
For each set of data, if Alice (Nana) finally wins, output "win"
If Bob finally wins, output "lose"
If the outcome cannot be separated, the output "Draw", (both do not include double quotes, pay attention to case, recommended copy)
Sample Input
251 2 3 4 551 2 3 4 6
Sample Output
Losewin
Hint
Example 1, at the beginning regardless of Nana chooses which two elements, the difference is included in the collection, so Nana can not operate, Bob Victory, output lose
Example 2, the first Nana can only choose 1 and 6 of these two elements, and put 6-1=5 into the collection, then the collection becomes 1,2,3,4,5,6 Bob cannot operate, Alice (Nana) win, output win
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <string>7#include <vector>8#include <Set>9#include <map>Ten#include <stack> One#include <queue> A#include <sstream> -#include <iomanip> - using namespacestd; thetypedefLong LongLL; - Const intINF =0x4fffffff; - Const DoubleEXP = 1e-5; - Const intMS =1005; + Const intSIZE =10005; - + intNum[ms]; A intFlag[ms]; at intN; - - intgcdintAintb) - { - returnb==0? A:GCD (b,a%b); - } in - intMain () to { + intT; -scanf"%d",&T); the while(t--) * { $scanf"%d",&n);Panax Notoginseng for(intI=0; i<n;i++) -scanf"%d",&num[i]); the intg=num[0]; + for(intI=1; i<n;i++) Ag=gcd (G,num[i]); the intmaxv=-INF; + for(intI=0; i<n;i++) - { $Num[i]/=G; $ if(num[i]>MAXV) -maxv=Num[i]; - } the intCnt=0; -memset (Flag,0,sizeof(flag));Wuyi for(intI=0; i<n;i++) the if(flag[i]==0) - { Wuflag[i]=1; -cnt++; About } $cnt=maxv-CNT; - if(cnt&1) -printf"win\n"); - Else Aprintf"lose\n"); + the } - return 0; $}
E-Nana in Wonderland Series--inexplicable episode