#include #include #include #include #include #include using namespace std; const bool debug=false; int gcd(int a,int b) { while(b) { int t=a%b; a=b; b=t; } return a; } bool isp[1001]; int N; int A[1000],B[1000]; int aA[1000],aB[1000]; int ask(int i,int j) { cout<<"? "<>x; return x; } void answer() { cout<<"!"; for(int i=0;i mt19937 rng; void setup() { random_device seed_gen; unsigned int seed=seed_gen(); //seed=1604191338; if(debug)cout<<"seed = "<>N; for(int i=2;i<=N;i++)isp[i]=true; for(int i=2;i<=N;i++)if(isp[i]) { for(int j=i+i;j<=N;j+=i)isp[j]=false; } if(N==1) { A[0]=B[0]=1; answer(); } if(N==2) { bool fn=false; int a,b; for(int i=0;!fn&&i<2;i++)for(int j=0;!fn&&j<2;j++) { if(ask(i,j)==1) { a=i,b=j; fn=true; } } A[0]=A[1]=B[0]=B[1]=2; A[a]=B[b]=1; answer(); } int T[1000]; int mini=0; for(int i=0;iT[i])mini=i; } A[0]=T[mini]; map >LtoB; for(int b=1;b<=N;b++) { int L=A[0]/gcd(A[0],b)*b; LtoB[L].push_back(b); } vector >Ps,nPs; for(int i=0;iN); int P=Ps.back().first,Pi=Ps.back().second; for(int i=1;ione; for(int i=0;itest; int ONE; for(int i=0;i=2); if(ask(one[0],test[0])%P!=0||ask(one[0],test[1])%P!=0)ONE=one[0]; else ONE=one[1]; A[one[0]+one[1]-ONE]=P; for(int i=0;i[1, 3], 2=>[2], 4=>[4]} //[6, 5] //{1=>[1, 5], 2=>[2], 3=>[3], 4=>[4], 6=>[6]} //[10, 7] //{1=>[1, 7], 2=>[2], 3=>[3], 4=>[4], 5=>[5], 6=>[6], 8=>[8], 9=>[9], 10=>[10]} vectortwo; for(int i=0;i