結果

問題 No.144 エラトステネスのざる
ユーザー mencottonmencotton
提出日時 2020-11-02 16:15:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 603 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 76,796 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 11:59:03
合計ジャッジ時間 19,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 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 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

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<ld> v(100, 1);
    for (int i = 1; i < 100; i++)v[i] = v[i - 1] * (1 - p);

    ld ret = 1;
    for (int i = 3; i <= n; i++) {
        ld count = 0;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                count++;
                if (j * j != i)count++;
            }
        }

        ret += v[count];
    }

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