結果

問題 No.3093 Please GCD
ユーザー 👑 platinumplatinum
提出日時 2022-04-01 22:57:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 205,260 KB
実行使用メモリ 825,304 KB
平均クエリ数 161.50
最終ジャッジ日時 2024-04-30 15:26:31
合計ジャッジ時間 7,511 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 21 ms
24,964 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 89 ms
24,580 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> p;
    for(int i = 2; i <= N; i++){
        int siz = p.size();
        bool is_prime = true;
        for(int j = 0; j < siz; j++){
            if(i % p[j] == 0) is_prime = false;
        }
        if(is_prime) p.emplace_back(i);
    }
    int p_siz = p.size();
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> prime(0, p_siz - 1);
    int ans = 1;
    int turn = 0;
    while(turn < 600){
        int d = prime(mt);
        turn++;
        cout << "? " << ans * p[d] << endl;
        int g;
        cin >> g;
        ans = g;
        if(ans > N / 2){
            cout << "! " << ans << endl;
            return 0;
        }
    }
    
    return 0;
}
0