結果

問題 No.3501 Digit Products 2
コンテスト
ユーザー Rubikun
提出日時 2026-04-17 20:14:40
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,104 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,475 ms
コンパイル使用メモリ 216,052 KB
実行使用メモリ 30,320 KB
平均クエリ数 10.85
最終ジャッジ日時 2026-04-17 20:15:04
合計ジャッジ時間 13,182 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 44 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

int ask(int a,int b){
    cout<<"? "<<a<<" "<<b<<endl;
    int c;cin>>c;
    return c;
}

int main(){
    
    int N;cin>>N;
    vi S(N),T;
    for(int i=1;i<N;i++){
        int x=ask(0,i);
        S[i]=x;
        if(x) T.pb(i);
    }
    
    if(si(T)==0){
        cout<<"! -1"<<endl;
    }else if(si(T)==1){
        int x=S[T[0]];
        vii ans;
        for(int a=1;a<=9;a++){
            for(int b=1;b<=9;b++){
                if((a*b)==x) ans.pb(mp(a,b));
            }
        }
        if(si(ans)==1){
            cout<<"! ";
            cout<<ans[0].fi;
            for(int i=1;i<N;i++){
                if(S[i]==0) cout<<0;
                else cout<<ans[0].se;
            }
            cout<<endl;
        }else{
            cout<<"! -1"<<endl;
        }
    }else{
        int z=ask(T[0],T[1]);
        for(int g=1;g<=9;g++){
            bool ok=true;
            for(int i=1;i<N;i++){
                ok&=(S[i]%g==0);
            }
            ok&=(S[T[0]]/g*S[T[1]]/g==z);
            
            if(ok){
                cout<<"! ";
                cout<<g;
                for(int i=1;i<N;i++){
                    cout<<S[i]/g;
                }
                cout<<endl;
                return 0;
            }
        }
    }
}


0