結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 49 ms
15,404 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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]);
    }

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