結果
問題 | No.2972 確率的素数判定 |
ユーザー |
![]() |
提出日時 | 2024-11-29 23:05:21 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 3,079 ms |
コンパイル使用メモリ | 244,992 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 23:05:30 |
合計ジャッジ時間 | 5,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 RE * 5 |
ソースコード
#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(101,1);prime[0]=0,prime[1]=0;for(int i=2;i<=100;i++){if(prime[i]){for(int j=i*2;j<=100;j+=i) prime[j]=0;}}V<int> cnt(101);for(int i=1;i<=100;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;}