結果

問題 No.3501 Digit Products 2
コンテスト
ユーザー Tehom
提出日時 2026-04-17 22:52:44
言語 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
結果
RE  
実行時間 -
コード長 1,467 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,214 ms
コンパイル使用メモリ 274,116 KB
実行使用メモリ 30,320 KB
平均クエリ数 2.85
最終ジャッジ日時 2026-04-17 22:53:20
合計ジャッジ時間 28,719 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other WA * 11 RE * 61
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}


void solve(){
  int n; cin >> n;

  int l=-1,lx=-1;
  int r=-1,rx=-1;
  vector<int> ans(n,-1);
  int now=n-2;
  bool can=true;
  while(1){
    cout << "? " << n-1 << " " << now << endl;
    int x; cin >> x;
    if(x == 0){
      ans[now]=0;
      now--;
    }
    else{
      if(l == -1){
        l=now;
        lx=x;
        now--;
      }
      else if(r == -1){
        r=now;
        rx=x;
        cout << "? " << l << " " << r << endl;
        int y; cin >> y;
        ans[n-1]=sqrt(lx*rx/y);
        ans[l]=lx/ans[n-1];
        ans[r]=rx/ans[n-1];
        now--;
      }
      else{
        ans[now]=x/ans[n-1];
        now--;
      }
    }
    if(now == -1){
      if(ans[n-1] == -1){
        cout << "! -1" << endl;
      }
      else{
        cout << "! ";
        for(int i=n-1;i>=0;i--){
          cout << ans[i];
        }
        cout << endl;
      }
      return;
    }
  }

  return;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int T=1;
  // cin >> T;
  while(T--) solve();
}
0