Interactive question: add after each output
fflush(stdout);
Question meaning: give a set: 44, 88, 1515, 1616, 2323, 4242. Now there is an array, which is an array of sets. Now you can ask judge J I four questions at most, "how much is a[i]*a[j]?" and then judge Ji will tell you the number. After that, you will output the array
Idea: since there are only four numbers and the product of two is unique, you can ask a[1]*a[2], a[1]*a[3], a[4]*a[5], a[4]*a[6]. Where a[1]*a[2] and a[1]*a[3] can determine a[1], a[2] and a[3]. a[4]*a[5] and a[4]*a[6] can determine a[4], a[5] and a[6]. In practice, write a pile of if
In fact, as long as I know to ask "a[1]*a[2], a[1]*a[3], a[4]*a[5], a[4]*a[6].", then we can enumerate all permutations, and the appropriate one is the answer
How to write a pile of if:
#include<bits/stdc++.h> #define fuck(x) std::cout<<"["<<#x<<"->"<<x<<"]"<<endl; using namespace std; typedef long long ll; const int M=2e5+5; const int inf=1e9+5; const int mod=1e9+7; map<int,pair<int,int> >mp; int x[]={4 , 8, 15, 16, 23, 42}; int main() { for(int i=0;i<6;i++){ for(int j=i+1;j<6;j++){ mp[x[i]*x[j]]=make_pair(i,j); } } int a,b,c,d,e,f; int ab; printf("? 1 2\n"); fflush(stdout); scanf("%d",&ab); int _a,_b; _a=mp[ab].first,_b=mp[ab].second; int ac; printf("? 1 3\n"); fflush(stdout); scanf("%d",&ac); int __a,_c; __a=mp[ac].first,_c=mp[ac].second; if(_a==__a){ a=_a; b=_b; c=_c; }else if(_a==_c){ a=_a; b=_b; c=__a; }else if(_b==__a){ a=_b; b=_a; c=_c; }else{ a=_b; b=_a; c=__a; } int de; printf("? 4 5\n"); fflush(stdout); scanf("%d",&de); int _d,_e; _d=mp[de].first,_e=mp[de].second; int df; printf("? 4 6\n"); fflush(stdout); scanf("%d",&df); int __d,_f; __d=mp[df].first,_f=mp[df].second; if(_d==__d){ d=_d; e=_e; f=_f; }else if(_d==_f){ d=_d; e=_e; f=__d; }else if(_e==__d){ d=_e; e=_d; f=_f; }else{ d=_e; e=_d; f=__d; } printf("! %d %d %d %d %d %d\n",x[a],x[b],x[c],x[d],x[e],x[f]); return 0; }
Enumeration arrangement:
#include<bits/stdc++.h> #define fuck(x) std::cout<<"["<<#x<<"->"<<x<<"]"<<endl; using namespace std; typedef long long ll; int x[]= {4, 8, 15, 16, 23, 42}; int main() { int ab; printf("? 1 2\n"); fflush(stdout); scanf("%d",&ab); int ac; printf("? 1 3\n"); fflush(stdout); scanf("%d",&ac); int de; printf("? 4 5\n"); fflush(stdout); scanf("%d",&de); int df; printf("? 4 6\n"); fflush(stdout); scanf("%d",&df); do { if(x[0]*x[1]==ab&&x[0]*x[2]==ac&&x[3]*x[4]==de&&x[3]*x[5]==df) { printf("! %d %d %d %d %d %d\n",x[0],x[1],x[2],x[3],x[4],x[5]); break; } } while(next_permutation(x,x+6)); return 0; }