結果

問題 No.144 エラトステネスのざる
ユーザー Pachicobue
提出日時 2018-12-19 21:04:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 74,060 KB
最終ジャッジ日時 2025-01-06 19:40:01
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using ld = long double;
int main()
{
    int N;
    ld P;
    std::cin >> N >> P;
    std::vector<ld> p(N + 1, 1);
    for (int i = 1; i <= N; i++) { p[i] = (1 - P) * p[i - 1]; }
    std::vector<int> cnt(N + 1, 0);
    for (int i = 2; i <= N; i++) {
        for (int j = 2; i * j <= N; j++) { cnt[i * j]++; }
    }
    ld ans = 0;
    for (int i = 2; i <= N; i++) { ans += p[cnt[i]]; }
    std::cout << ans << std::endl;
    return 0;
}
0