結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2022-07-24 21:32:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 2,044 ms |
コンパイル使用メモリ | 195,220 KB |
最終ジャッジ日時 | 2025-01-30 13:52:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; double p; cin>>n>>p; vector<double> D(1000100); D[0]=1.0; for(int i=1;i<1000100;i++) D[i]=D[i-1]*(1-p); vector<int> dp(n+1); for(int i=2;2*i<=n;i++){ for(int j=2*i;j<=n;j+=i) dp[j]++; } double ans=0; for(int i=2;i<=n;i++) ans+=D[dp[i]]; printf("%.10f\n",ans); return 0; }