题目 :Problem - 1536 (hdu.edu.cn)
#include<bits/stdc++.h>
using namespace std;
int a[110],f[10010];
int k;
int sg(int b){int t;bool g[10010]={0};for(int i=0;i<k;i++){t=b-a[i];if(t<0){break;}if(f[t]==-1){f[t]=sg(t);}g[f[t]]=1;}for(int h=0;;h++){if(!g[h]){return h;}}
}
int main(){int ki,m,l,li;while(scanf("%d",&k)==1&&k){for(int i=0;i<k;i++){scanf("%d",&ki);a[i]=ki;}sort(a,a+k);memset(f,-1,sizeof f);f[0]=0;scanf("%d",&m);while(m--){scanf("%d",&l);int s=0;while(l--){scanf("%d",&li);if(f[li]==-1){f[li]=sg(li);}s^=f[li];}if(s==0){printf("L");}else{printf("W");}}printf("\n");}return 0;
}