娜娜梦游仙境系列——莫名其妙的插曲
娜娜因为帮桃花村民们解决了一大难题而受到村民们的尊敬,不过由于娜娜还想继续探索这个神奇的世界,只好恋恋不舍地与村民告别。当娜娜离开村庄的一刻,娜娜失忆了!她不记得桃花村的一切,她不记得之前吃了很多糖果,她不记得她为了过湖而跳了半天,甚至她连自己的名字都不记得了!娜娜盲目地四处溜达,突然迎面走来了一个白马王子,他问:“你是Alice吗?”。娜娜心想:“Alice?好熟的名字啊,难道这就是我的名字吗?",便回答:”是的。请问您是?“白马王子很高兴地说:”我叫Bob,我找你找了一辈子了,没有你,我总是被父王忘记,我们回王宫吧!"于是娜娜就迷迷糊糊地被带到了王宫。
国王:“你就是Alice?怎么士别三日,你变痴呆了啊,你先和我的儿子Bob先玩一玩游戏,我看看你是不是脑子有问题。”娜娜为了证明自己脑子没问题,只好与Bob玩起了游戏。
游戏规则很简单,一开始有一个集合,集合里有n个不同的数,然后Alice(娜娜)与Bob轮流进行操作,每人都可以任意选择两个数a,b,不妨设a>b,不过要求a-b不在集合中,把a-b放入集合。如果轮到某人,无法进行任何操作,则该人输掉游戏。作为职业博弈选手,娜娜即使失忆了也能凭着身体的直觉去进行最优操作。那么问,当Alice(娜娜)与Bob都沿着最优策略进行,女士优先(即娜娜先手),最终谁会获胜?
多组数据,首先是一个正整数t(t<=20),表示数据的组数
对于每组数据,首先是一个整数n(1<=n<=1,000),然后是n个整数x[i](0<x[i]<=1,000,000,000),表示集合。保证集合元素不会出现相同。
对于每组数据,若Alice(娜娜)最终胜利,输出"Win"
若Bob最终胜利,输出"Lose"
若无法分出胜负,输出"Draw",(均不包括双引号,注意大小写,建议复制)
2 5 1 2 3 4 5 5 1 2 3 4 6
Lose Win提示: 样例1,一开始无论娜娜选择哪两个元素,其差值均包括在集合中,故娜娜无法操作,Bob胜利,输出Lose 样例2,一开始娜娜只能选择1和6这两个元素,并把6-1=5放入集合中,则集合变为1,2,3,4,5,6 Bob无法操作,Alice(娜娜)胜利,输出Win
//china no.1
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <cstring>
#include <queue>
#include <list>
#include <stdio.h>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include <functional>
#include <stdlib.h>
#include <time.h>
#include <bitset>
using namespace std;
#define pi acos(-1)
#define endl '\n'
#define srand() srand(time(0));
#define me(x,y) memset(x,y,sizeof(x));
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define close() ios::sync_with_stdio(0); cin.tie(0);
#define FOR(x,n,i) for(int i=x;i<=n;i++)
#define FOr(x,n,i) for(int i=x;i<n;i++)
#define W while
#define sgn(x) ((x) < 0 ? -1 : (x) > 0)
#define bug printf("***********\n");
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL LINF=0x3f3f3f3f3f3f3f3fLL;
const int dx[]={-1,0,1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,-1,1,-1,1};
const int maxn=1e3+10;
const int maxx=1e4+100;
const double EPS=1e-7;
const int mod=10000007;
#define mod(x) ((x)%MOD);
template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}
template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}
template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}
template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}
inline LL Scan()
{
int f=1;char C=getchar();LL x=0;
while (C<'0'||C>'9'){if (C=='-')f=-f;C=getchar();}
while (C>='0'&&C<='9'){x=x*10+C-'0';C=getchar();}
x*=f;return x;
}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.out" , "w" , stdout );
//cerr << "run time is " << clock() << endl;
int gcd(int a,int b)
{
if(b!=0) return gcd(b,a%b);
else return a;
}
int main()
{
int t,n;
int a[maxx];
while(scanf("%d",&t)!=EOF)
{
while(t--)
{
scanf("%d",&n);
int maxc=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(maxc<a[i])
maxc=a[i];
}
if(n==1)//此处*
{
puts("Lose");
continue;
}
int g=0,m;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
m=gcd(a[i],a[j]);
if(g==0||g>m)
g=m;
if(m==1)break;
}
if(m==1)break;
}
m=maxc/g-n;
if(m&1)
puts("Win");
else puts("Lose");
}
}
}