結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
typedef long long ll;
typedef long double lb;
using namespace std;
using namespace atcoder;
#define all(x) (x).begin(), (x).end()
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP1(i, n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
template<class T> bool chmin(T& a, const T& b){if(a > b){a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b){if(a < b){a = b; return 1;} return 0;}
const ll INF = 1000000000000000000; // 10^18

int main(){
    ll n;
    cin >> n;
    vector<ll> v(n-1);
    ll non_zero_1 = -1;
    ll non_zero_2 = -1;
    string s = "! ";
    //v[i] 10^n-1と10^iの積
    for(int i = 0;i < n-1;i++){
        cout << "? " << i << " " << n-1 << endl;
        cin >> v[i];
        if(v[i] != 0 && non_zero_1 == -1){
            non_zero_1 = i;
        }else if(v[i] != 0 && non_zero_2 == -1){
            non_zero_2 = i;
        }
    }
    vector<bool> d(9,true);
    ll true_count = 9;
    //d[i] : 10^n-1が、i+1であれば、true
    for(int i = 1;i <= 9;i++){
        rep(j,v.size()){
            if(v[j] % (i) != 0){
                d[i-1] = false;
                true_count--;
                break;
            }
        }
    }
    if(true_count == 1){
        //cout << "! ";
        ll nn = -1;
        for(int i = 1;i <= 9;i++){
            if(d[i-1] == true){
                nn = i;
                // cout << i;
                s += to_string(i);
            }
        }
        for(int i = n-2;i >= 0;i--){
            // cout << v[i] / nn;
            s += to_string(v[i]/nn);
        }
        //cout << endl;
    }else if(non_zero_2 == -1){
        int t = n;
        int x = 2/(t-n);
        cout <<  "! " << -1 << endl;
        return 0;
    }else{
        cout << "? " << non_zero_1 << " " << non_zero_2 << endl;
        ll tmp;
        cin >> tmp;
        ll nn = (ll)sqrt((double)v[non_zero_1]*(double)v[non_zero_2]/(double)tmp);
        //cout << "! " << nn;
        s += to_string(nn);
        for(int i = n-2;i >= 0;i--){
            // cout << v[i] / nn;
            s += to_string(v[i] / nn);
        }
        //cout << endl;
    }
    if(s.size() != n+2){
        int t = n;
        int x = 2/(t-n);
    }else{
        cout << s << endl;
    }
    return 0;
}
0