結果

問題 No.8093 Please GCD
ユーザー platinum
提出日時 2022-04-01 23:07:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 197,372 KB
最終ジャッジ日時 2025-01-28 14:22:52
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 25 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

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;
        }
    }
    cout << "! " << ans << endl;
    
    return 0;
}
0