結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2023-11-14 00:41:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 440 bytes |
コンパイル時間 | 3,672 ms |
コンパイル使用メモリ | 228,756 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-09-26 03:28:09 |
合計ジャッジ時間 | 4,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; int main() { int N; double p; cin >> N >> p; vector<double> dp(N + 1, 1); double ans = 0; for (int x = 2; x <= N; x++) { ans += dp[x]; for (int i = 2; x * i <= N; i++) { dp[x * i] *= 1 - p; } // cerr << dp[x] << ' '; } // cerr << endl; cout << fixed << setprecision(10) << ans << endl; }