結果

問題 No.3501 Digit Products 2
コンテスト
ユーザー dayo ZOI
提出日時 2026-04-18 22:38:23
言語 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
結果
RE  
実行時間 -
コード長 1,285 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,386 ms
コンパイル使用メモリ 177,132 KB
実行使用メモリ 30,320 KB
平均クエリ数 4.26
最終ジャッジ日時 2026-04-18 22:38:49
合計ジャッジ時間 9,341 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other AC * 21 RE * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int sqrt(ll)':
main.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^

ソースコード

diff #
raw source code

#include <string>
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0; i<n; ++i)

int sqrt(ll x) {
    for(int i=1; i<10; i++) if(x == i * i) return i;
}

int main() {
    ll n;
    cin >> n;
    if(n == 2) {
        cout << "? 0 1" << endl;
        ll ret;
        cin >> ret;
        if(ret == 1) {
            cout << "! 11" << endl;
        } else if(ret == 25) {
            cout << "! 55" << endl;
        } else if(ret == 49) {
            cout << "! 77" << endl;
        } else if(ret == 64) {
            cout << "! 88" << endl;
        } else if(ret == 81) {
            cout << "! 99" << endl;
        } else {
            cout << "! -1" << endl;
            return 1;
        }
    } else {
        vector<ll> res(n);
        rep(i, n-1){
            cout << "? 0 " << i+1 << endl;
            cin >> res[i+1];
            if(res[i+1] == 0) {
                cout << "! -1" << endl;
                return 1;
            }
        }
        cout << "? 1 2" << endl;
        ll res12;
        cin >> res12;
        res[0] = res[1] * res[2] / res12;
        ll a0 = sqrt(res[0]);
        cout << "! ";
        rep(i, n) {
            cout << res[n-1-i] / a0;
        }
        cout << endl;
    }
}
0