結果

問題 No.3093 Please GCD
ユーザー Nzt3Nzt3
提出日時 2022-04-03 19:37:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 174,864 KB
実行使用メモリ 25,476 KB
平均クエリ数 336.80
最終ジャッジ日時 2024-05-03 04:37:39
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
24,964 KB
testcase_01 AC 21 ms
25,220 KB
testcase_02 AC 19 ms
24,836 KB
testcase_03 AC 83 ms
25,220 KB
testcase_04 AC 27 ms
24,580 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 66 ms
24,964 KB
testcase_08 AC 22 ms
24,836 KB
testcase_09 AC 28 ms
24,836 KB
testcase_10 AC 19 ms
24,580 KB
testcase_11 AC 21 ms
24,964 KB
testcase_12 AC 31 ms
25,220 KB
testcase_13 AC 33 ms
24,836 KB
testcase_14 AC 73 ms
24,964 KB
testcase_15 AC 25 ms
25,220 KB
testcase_16 AC 23 ms
24,836 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 92 ms
25,220 KB
testcase_20 AC 22 ms
25,220 KB
testcase_21 AC 23 ms
25,208 KB
testcase_22 WA -
testcase_23 AC 27 ms
25,220 KB
testcase_24 AC 31 ms
25,112 KB
testcase_25 WA -
testcase_26 AC 39 ms
25,220 KB
testcase_27 AC 26 ms
25,476 KB
testcase_28 AC 24 ms
25,476 KB
testcase_29 AC 60 ms
25,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>prime(N+1,1);
  vector<int>ask1,ask2;
  for(int i=2;i<=N;i++){
    if(prime[i]==0)continue;
    int t=i;
    while(t*i<=N)t*=i;
    if(t!=i)ask1.push_back(t);
    else ask2.push_back(t);
    for(int j=i*i;j<=N;j+=i){
      prime[j]=0;
    }
  }
  long long ans=1;
  int cnt=0;
  for(int i=0,t;i<min(600,(int)ask1.size());i++,cnt++){
    cout<<"? "<<ask1[i]<<endl;
    cin>>t;
    ans*=t;
  }
  random_device sd;
  mt19937 rd(sd());
  while(ask2.size()&&ans*ask2.back()>N)ask2.pop_back();
  shuffle(ask2.begin(),ask2.end(),rd);
  for(int i=0,t;i<min(600-cnt,(int)ask2.size());i++){
    cout<<"? "<<ask2[i]<<endl;
    cin>>t;
    ans*=t;
  }
  cout<<"! "<<ans<<'\n';
}
0