constint INF = ~0u>>1; typedef pair <int,int> P; #define MID(x,y) ((x+y)>>1) #define iabs(x) ((x)>0?(x):-(x)) #define REP(i,a,b) for(int i=(a);i<(b);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define pb push_back #define mp make_pair #define print() cout<<"--------"<<endl int n,m; int sg[1010],ni[1010]; intmex(int num){ if (sg[num] != -1) return sg[num]; int judge[1010] = {0}; int tmp; for (int i = 0; i < n; i++){ tmp = num - ni[i]; if (tmp < 0) break; for (int j = tmp; j >= 0; j--){ judge[mex(j) ^ mex(num-j-ni[i])] = 1; } } for (int i = 0;;i++) if (!judge[i]) return sg[num] = i; }
intmain(){ while (~scanf("%d", &n)){ memset(sg,-1,sizeof(sg)); for (int i = 0; i < n; i++) scanf("%d", &ni[i]); sort(ni, ni + n); int i ,j; for (i = j = 1; i < n; i++){ if (ni[i] != ni[j-1]) ni[j++] = ni[i]; } n = j; scanf("%d", &m); int num,sgans = 0; for (int i = 0; i < m; i++){ scanf("%d", &num);
// sgans ^= mex(num);
if (mex(num) == 0) printf("2n"); elseprintf("1n"); } } return0; }