結果

問題 No.144 エラトステネスのざる
ユーザー kpinkcatkpinkcat
提出日時 2023-10-31 03:34:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,370 ms
コンパイル使用メモリ 204,956 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-10-31 03:35:03
合計ジャッジ時間 3,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 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 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 49 ms
15,408 KB
testcase_14 AC 57 ms
15,412 KB
testcase_15 AC 57 ms
15,408 KB
testcase_16 AC 56 ms
15,408 KB
testcase_17 AC 58 ms
15,408 KB
testcase_18 AC 59 ms
15,412 KB
testcase_19 AC 44 ms
15,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int divisor(int n) {
    int ret = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret++;
            if (i*i != n) ret++;
        }
    }
    return (ret - 2);
}

int main(){
    int n;
    double p;
    cin >> n >> p;
    vector<int> fac(n+1);
    vector<double> yprime(n+1);
    for (int i = 2; i <= n; i++){
        for (int j = i; j <= n; j += i){
            fac[j]++;
        }
    }
    
    for (int i = 2; i <= n; i++){
        int ex = 0;
        double tmp = 1.0;
        yprime[i] = yprime[i-1] + pow(1-p, fac[i]-1);
    }

    cout << fixed << setprecision(7) << yprime[n] << endl;
}
0