結果

問題 No.2972 確率的素数判定
ユーザー umezo
提出日時 2024-11-29 23:08:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 2,693 ms
コンパイル使用メモリ 244,888 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 23:08:08
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  V<int> prime(100001,1);
  prime[0]=0,prime[1]=0;
  for(int i=2;i<=100000;i++){
    if(prime[i]){
      for(int j=i*2;j<=100000;j+=i) prime[j]=0;
    }
  }
  V<int> cnt(100001);
  for(int i=1;i<=100000;i++) cnt[i]=cnt[i-1]+prime[i];
  
  int t;
  cin>>t;
  while(t--){
    int n;
    double p,q;
    cin>>n>>p>>q;
    double ans=(double)cnt[n]*p/(cnt[n]*p+(n-cnt[n])*(100-q));
    printf("%.10f\n",ans);
  }
    
  return 0;
}
0