标签:
题目:
Description
Input
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int s[105],sg[10001]; 6 bool mex[10001]; 7 void get_sg(int t,int n) 8 { 9 int i,j; 10 memset(sg,0,sizeof(sg)); 11 for(i=1;i<=n;i++) 12 { 13 memset(mex,0,sizeof(mex)); 14 for(j=1;j<=t&&s[j]<=i;j++) 15 mex[sg[i-s[j]]]=1; 16 for(j=0;j<=n;j++) 17 if(!mex[j]) 18 break; 19 sg[i]=j; 20 } 21 } 22 int main() 23 { 24 int k; 25 while(cin>>k,k) 26 { 27 for(int i=1;i<=k;i++) 28 cin>>s[i]; 29 sort(s+1,s+k+1); 30 get_sg(k,10001); 31 int m,n,ans,t; 32 cin>>m; 33 while(m--) 34 { 35 cin>>n; 36 ans=0; 37 for(int i=0;i<n;i++) 38 { 39 cin>>t; 40 ans^=sg[t]; 41 } 42 if(ans) 43 cout<<‘W‘; 44 else 45 cout<<‘L‘; 46 } 47 cout<<endl; 48 } 49 return 0; 50 }
标签:
原文地址:http://www.cnblogs.com/forwin/p/4890405.html