結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2024-11-21 14:43:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 749 ms |
コンパイル使用メモリ | 79,252 KB |
実行使用メモリ | 11,404 KB |
最終ジャッジ日時 | 2024-11-21 14:43:06 |
合計ジャッジ時間 | 2,086 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <iomanip>#include <cstdint>#include <vector>using namespace std;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);uint32_t N, i, j;double p;cin >> N >> p;vector<double> dp(N + 1, 1);double ans = 0;dp[0] = dp[1] = 1;for (i = 2; i <= N; ++i){ans += dp[i];for (j = i * 2; j <= N; j += i)dp[j] *= 1 - p;}cout << fixed << setprecision(10) << ans << '\n';return 0;}