結果

問題 No.144 エラトステネスのざる
ユーザー mencottonmencotton
提出日時 2020-11-02 16:20:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 78,424 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2023-09-29 11:59:19
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 29 ms
7,096 KB
testcase_16 AC 30 ms
7,092 KB
testcase_17 AC 29 ms
7,140 KB
testcase_18 AC 29 ms
7,036 KB
testcase_19 AC 29 ms
7,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;
using ld = long double;

int main() {
    int n;
    ld p;
    cin >> n >> p;

    vector<int> count(n + 1);
    for (int i = 2; i <= n; i++) {
        for (int j = i * 2; j <= n; j += i)count[j]++;
    }

    vector<ld> v(200, 1);
    for (int i = 1; i < 200; i++)v[i] = v[i - 1] * (1 - p);

    ld ret = 1;
    for (int i = 3; i <= n; i++) ret += v[count[i]];

    cout << fixed << setprecision(15) << ret << endl;
    return 0;
}
0