結果

問題 No.144 エラトステネスのざる
ユーザー mencotton
提出日時 2020-11-02 16:19:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 79,460 KB
実行使用メモリ 7,456 KB
最終ジャッジ日時 2024-07-22 06:21:05
合計ジャッジ時間 1,522 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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; j <= n; j += i)count[j]++;
    }

    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++) ret += v[count[i] - 1];

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