結果

問題 No.3501 Digit Products 2
コンテスト
ユーザー Bokuneko
提出日時 2026-04-18 00:53:22
言語 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
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,181 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,230 ms
コンパイル使用メモリ 333,484 KB
実行使用メモリ 30,320 KB
平均クエリ数 11.18
最終ジャッジ日時 2026-04-18 00:53:39
合計ジャッジ時間 10,906 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int solve(){
  
  return 0;
}
 
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  int k0 = -1;
  int d1 = -1;
  int d2 = -1;
  int k1 = -1;
  int k2 = -1;
  for(int i = 0; i < N-1; i++){
    cout << "? " << i << " " << N-1 << endl;
    cin >> P[i];
    if(P[i] == -1){
      return 0;
    }
    if(d1 == -1 && P[i] != 0){
      d1 = i;
      k1 = P[i];
    }
    else if(d2 == -1 && P[i] != 0){
      d2 = i;
      k2 = P[i];
    }
  }
  if(d2 != -1){
    cout << "? " << d1 << " " << d2 << endl;
    cin >> k0;
    double k3;
    k3 = k1 * k2 / k0;
    P[N-1] = sqrt(k3);
    cout << "! " << P[N-1];
    for(int i = 1; i < N; i++){
      cout << P[N-i-1] / P[N-1];
    }
    cout << endl;
  }
  else{
    if(k1 == 1 || k1 == 25 || k1 == 49 || k1 == 64 || k1 == 81){
      d2 = N-1;
      k2 = k1;
      cout << "? " << d1 << " " << d2 << endl;
      cin >> k0;
      double k3;
      k3 = k1 * k2 / k0;
      P[N-1] = sqrt(k3);
      cout << "! " << P[N-1];
      for(int i = 1; i < N; i++){
        cout << P[N-i-1] / P[N-1];
      }
      cout << endl;
    }
    else{
      cout << "! " << -1 << endl;
    }
  }
  return 0;
}
0