結果

問題 No.144 エラトステネスのざる
ユーザー bin101bin101
提出日時 2019-10-02 14:02:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 72,524 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2024-04-14 08:55:42
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 44 ms
7,884 KB
testcase_14 AC 52 ms
7,624 KB
testcase_15 AC 51 ms
7,924 KB
testcase_16 AC 51 ms
7,748 KB
testcase_17 AC 52 ms
7,808 KB
testcase_18 AC 54 ms
7,736 KB
testcase_19 AC 38 ms
7,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int d[1100000];

int main(){
    int N;
    double p,ans=0.0;
    cin>>N>>p;

    for(int k=2;k<=N;k++){
        for(int m=k;m<=N;m+=k){
            d[m]++;
        }
        ans+=pow(1-p,d[k]-1);
    }
    printf("%.6lf\n",ans);
}
0