結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2024-12-30 23:20:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 401 bytes |
コンパイル時間 | 5,073 ms |
コンパイル使用メモリ | 276,832 KB |
実行使用メモリ | 7,428 KB |
最終ジャッジ日時 | 2024-12-30 23:20:52 |
合計ジャッジ時間 | 6,326 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <iomanip> using namespace std; int main() { int N; cin >> N; double P; cin >> P; double ans = 0; vector<int> div(N+1); for (int i=2;i<=N;i++) { for (int j=i;j<=N;j+=i) div[j]++; double E = 1.0; for (int e=0;e<div[i]-1;e++) E *= (1.0 - P); ans += E; } cout << fixed << setprecision(16) << ans << endl; }