結果

問題 No.144 エラトステネスのざる
ユーザー nvt4snvt4s
提出日時 2019-05-26 18:55:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 170,340 KB
実行使用メモリ 7,368 KB
最終ジャッジ日時 2023-10-17 18:01:18
合計ジャッジ時間 3,057 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
7,308 KB
testcase_01 AC 30 ms
7,308 KB
testcase_02 AC 30 ms
7,308 KB
testcase_03 AC 30 ms
7,308 KB
testcase_04 AC 32 ms
7,308 KB
testcase_05 AC 30 ms
7,308 KB
testcase_06 AC 30 ms
7,308 KB
testcase_07 AC 30 ms
7,368 KB
testcase_08 AC 30 ms
7,308 KB
testcase_09 AC 30 ms
7,308 KB
testcase_10 AC 30 ms
7,308 KB
testcase_11 AC 30 ms
7,368 KB
testcase_12 AC 30 ms
7,308 KB
testcase_13 AC 46 ms
7,308 KB
testcase_14 AC 54 ms
7,368 KB
testcase_15 AC 54 ms
7,308 KB
testcase_16 AC 55 ms
7,308 KB
testcase_17 AC 54 ms
7,308 KB
testcase_18 AC 56 ms
7,368 KB
testcase_19 AC 41 ms
7,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

//約数の個数の列挙
//nlogn
vector<int> num_divisors_list(int n){
    vector<int> num(n+1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            num[j]++;
        }
    }
    return num;
}


int main(void){
    int N;
    double p;
    cin >> N >> p;
    double ans = 0.0;
    vector<int> num = num_divisors_list(1000010);
    for(int i = 2; i <= N; i++){
        int x = num[i];
        x -= 2;
        ans += pow((1.0-p), x);
    }
    cout << fixed << setprecision(10) << ans << endl;
}
0