結果

問題 No.3093 Please GCD
ユーザー hourenhouren
提出日時 2022-04-01 22:16:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 169,904 KB
実行使用メモリ 25,476 KB
平均クエリ数 505.87
最終ジャッジ日時 2024-04-30 14:23:14
合計ジャッジ時間 8,330 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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>n) break;
            cout << "? " << out << endl;
            cin >> res;
            if(res==pre) break;
            pre = res;
        }
        ans *= pre;
    }
    cout << "! " << ans << endl;
    return 0;
}
0