没咋接触过交互题
题意:给了6个数分别是4,8,15,16,23,42。会由coder询问四次,询问的方式为“? a b”。
每次询问会由oj返回1个数,这个数为a,b的积。然后让你求出这六个数的顺序。
询问为cout
得到oj返回的数为cin
#include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <map> #include <iomanip> #include <algorithm> #include <queue> #include <stack> #include <set> #include <vector> // #include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sp ' ' #define inf 0x3f3f3f3f; #define FOR(i,a,b) for( int i = a;i <= b;++i) #define bug cout<<"--------------"<<endl #define P pair<int, int> #define fi first #define se second #define pb(x) push_back(x) #define ppb() pop_back() #define mp(a,b) make_pair(a,b) #define ms(v,x) memset(v,x,sizeof(v)) #define rep(i,a,b) for(int i=a;i<=b;i++) #define repd(i,a,b) for(int i=a;i>=b;i--) #define sca3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c)) #define sca2(a,b) scanf("%d %d",&(a),&(b)) #define sca(a) scanf("%d",&(a)); #define sca3ll(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c)) #define sca2ll(a,b) scanf("%lld %lld",&(a),&(b)) #define scall(a) scanf("%lld",&(a)); using namespace std; typedef long long ll; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll powmod(ll a, ll b, ll mod){ll sum = 1;while (b) {if (b & 1) {sum = (sum * a) % mod;b--;}b /= 2;a = a * a % mod;}return sum;} const double Pi = acos(-1.0); const double epsilon = Pi/180.0; const int maxn = 2e5+10; int q[7] = {4,8,15,16,23,42}; int main() { int a,b,c,d; cout<<"?"<<sp<<1<<sp<<2<<endl; cin>>a; cout<<"?"<<sp<<1<<sp<<3<<endl; cin>>b; cout<<"?"<<sp<<4<<sp<<5<<endl; cin>>c; cout<<"?"<<sp<<4<<sp<<6<<endl; cin>>d; do{ if((a==q[1]*q[0])&&(b==q[0]*q[2])&&(c==q[3]*q[4])&&(d==q[3]*q[5])){ cout<<"! "; rep(i,0,5){ cout<<q[i]<<sp; } //cout<<endl; } }while(next_permutation(q,q+6)); }