結果

問題 No.144 エラトステネスのざる
ユーザー buey_tbuey_t
提出日時 2022-12-12 01:23:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 81,548 KB
実行使用メモリ 46,328 KB
最終ジャッジ日時 2024-04-23 19:31:07
合計ジャッジ時間 14,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1,864 ms
46,324 KB
testcase_14 AC 1,853 ms
46,324 KB
testcase_15 WA -
testcase_16 AC 1,872 ms
46,328 KB
testcase_17 AC 1,858 ms
46,324 KB
testcase_18 AC 1,881 ms
46,324 KB
testcase_19 AC 1,841 ms
46,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
#include <cmath>

using namespace std;

int main()
{
    double N, p;
    cin >> N >> p;
    int N_int = (int)N;
    double ans = 0;

    unordered_map<int, int> memo;
    for (int i = 2; i <= N_int; i++)
    {
        for (int j = i; j <= N_int; j += i)
        {
            memo[j] += 1;
        }
        ans += pow(1 - p, memo[i]-1);
    }

    cout << ans << endl;

    return 0;
}

0