結果

問題 No.144 エラトステネスのざる
ユーザー 👑 hitonanodehitonanode
提出日時 2020-09-24 22:38:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 200,328 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2023-09-10 14:05:21
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    cout << fixed << setprecision(20);
    int N;
    double p;
    cin >> N >> p;
    vector<double> pow2(10001, 1.0);
    for (size_t i = 1; i < pow2.size(); i++) pow2[i] = pow2[i - 1] * (1.0 - p);

    double ret = 0.0;
    vector<int> cnt(N + 1);
    for (int i = 2; i <= N; i++)
    {
        ret += pow2[cnt[i]];
        for (int j = i; j <= N; j += i) cnt[j]++;
    }
    cout << ret << '\n';
}
0