結果

問題 No.144 エラトステネスのざる
ユーザー aa
提出日時 2023-11-14 00:40:27
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 434 bytes
コンパイル時間 5,192 ms
コンパイル使用メモリ 309,276 KB
実行使用メモリ 17,912 KB
最終ジャッジ日時 2023-11-14 00:40:39
合計ジャッジ時間 9,709 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0