結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-05 19:33:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 1,480 ms |
| コンパイル使用メモリ | 166,524 KB |
| 実行使用メモリ | 11,576 KB |
| 最終ジャッジ日時 | 2024-10-11 00:58:36 |
| 合計ジャッジ時間 | 2,464 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
double dp[MAX_N + 1];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
double p;
cin >> n >> p;
p = 1 - p;
fill(dp + 2, dp + n + 1, 1.0);
for (int i = 2; i <= n / 2; i++) {
for (int j = 2; i * j <= n; j++) {
dp[i * j] *= p;
}
}
double ans = 0.0;
for (int i = 2; i <= n; i++) ans += dp[i];
printf("%.10lf\n", ans);
return 0;
}