結果

問題 No.8093 Please GCD
ユーザー houren
提出日時 2022-04-01 22:21:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 169,464 KB
実行使用メモリ 25,476 KB
平均クエリ数 198.93
最終ジャッジ日時 2024-11-20 09:56:29
合計ジャッジ時間 6,042 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, res = 1, pre, now = 2, out, ans = 1;
    cin >> n;
    vector<bool> pn(n+100,true);
    while(res>=0){
        out = pre = 1;
        while(!pn[now]) now++;
        if(now>n) break;
        for(int i=now;i<=n;i+=now) pn[i] = false;
        while(res>=0){
            out *= now;
            if(out*ans>n) break;
            cout << "? " << out << '\n' << flush;
            cin >> res;
            if(res==pre) break;
            pre = res;
        }
        ans *= pre;
    }
    cout << "! " << ans << '\n' << flush;
    return 0;
}
0