結果

問題 No.144 エラトステネスのざる
ユーザー ks115ks115
提出日時 2020-11-28 23:59:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 201,032 KB
実行使用メモリ 7,180 KB
最終ジャッジ日時 2023-10-11 02:04:25
合計ジャッジ時間 4,070 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 56 ms
7,116 KB
testcase_14 AC 73 ms
7,012 KB
testcase_15 AC 81 ms
7,000 KB
testcase_16 AC 77 ms
7,036 KB
testcase_17 AC 77 ms
7,116 KB
testcase_18 AC 78 ms
7,180 KB
testcase_19 AC 50 ms
7,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; double P; cin >> N >> P;

    vector<int> divisor(N + 1, 0); double ans = 0;
    REP(i, 2, N + 1) {
        for (int j = i + i; j <= N; j += i) {
            divisor[j]++;
        }
        ans += pow(1 - P, divisor[i]);
    }
    
    cout << fixed << setprecision(15);
    cout << ans << endl;
    return 0;
}
0