結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 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 1 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 1 ms
5,376 KB
testcase_13 AC 1,186 ms
46,192 KB
testcase_14 AC 1,189 ms
46,324 KB
testcase_15 WA -
testcase_16 AC 1,217 ms
46,320 KB
testcase_17 AC 1,305 ms
46,452 KB
testcase_18 AC 1,255 ms
46,328 KB
testcase_19 AC 1,245 ms
46,192 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 + i; j <= N_int; j += i)
        {
            memo[j] += 1;
        }
        ans += pow(1 - p, memo[i]);
    }

    cout << ans << endl;

    return 0;
}

0