fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. struct pro{
  5. int pr,a, b;
  6. };
  7. int main() {
  8. int a[6]={4,8,15,16,23,42};
  9. vector<pro>p;
  10. for(int i=0; i<6; i++){
  11. for(int j=i+1; j<6; j++){
  12. pro x;
  13. x.a=a[i];
  14. x.b=a[j];
  15. x.pr=a[i]*a[j];
  16. p.push_back(x);
  17. }
  18. }
  19. int ans[7]={0,};
  20. cout<<"? "<<1<<" "<<6<<endl;
  21. int q;
  22. cin>>q;
  23. for(pro y:p){
  24. if(q==y.pr){
  25. ans[1]=y.a;
  26. ans[6]=y.b;
  27. }
  28. }
  29. cout<<"? "<<2<<" "<<5<<endl;
  30. cin>>q;
  31. for(pro y:p){
  32. if(q==y.pr){
  33. ans[2]=y.a;
  34. ans[5]=y.b;
  35. }
  36. }
  37. int f=3;
  38. for(int i:a){
  39. int k=0;
  40. for(int j:ans){
  41. if(i==j) k=1;
  42. }
  43. if(k==0){
  44. ans[f]=i;
  45. f=4;
  46. }
  47. }
  48. cout<<"? "<<2<<" "<<3<<endl;
  49. cin>>q;
  50. if(ans[2]*ans[3]!=q){
  51. swap(ans[3], ans[4]);
  52. if(ans[2]*ans[3]!=q){
  53. swap(ans[2], ans[5]);
  54. if(ans[2]*ans[3]!=q){
  55. swap(ans[3], ans[4]);
  56. }
  57. }
  58. }
  59. cout<<"? "<<1<<" "<<2<<endl;
  60. cin>>q;
  61. if(ans[1]*ans[2]!=q){
  62. swap(ans[1],ans[6]);
  63. }
  64. cout<<"! ";
  65. for(int i=1; i<=6; i++) cout<<ans[i]<<" ";
  66. cout<<endl;
  67. return 0;
  68. }
Success #stdin #stdout 0s 5320KB
stdin
16
64
345
672
stdout
? 1 6
? 2 5
? 2 3
? 1 2
! 0 16 8 42 4 0