結果

問題 No.144 エラトステネスのざる
ユーザー chocoruskchocorusk
提出日時 2018-10-13 03:43:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 90,576 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-20 19:58:32
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,520 KB
testcase_01 AC 6 ms
11,392 KB
testcase_02 AC 6 ms
11,520 KB
testcase_03 AC 6 ms
11,520 KB
testcase_04 AC 5 ms
11,392 KB
testcase_05 AC 5 ms
11,392 KB
testcase_06 AC 7 ms
11,520 KB
testcase_07 AC 6 ms
11,264 KB
testcase_08 AC 6 ms
11,520 KB
testcase_09 AC 7 ms
11,520 KB
testcase_10 AC 7 ms
11,520 KB
testcase_11 AC 6 ms
11,392 KB
testcase_12 AC 6 ms
11,392 KB
testcase_13 AC 48 ms
11,520 KB
testcase_14 AC 49 ms
11,392 KB
testcase_15 AC 48 ms
11,520 KB
testcase_16 AC 48 ms
11,392 KB
testcase_17 AC 49 ms
11,264 KB
testcase_18 AC 50 ms
11,520 KB
testcase_19 AC 48 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	double p0;
	cin>>n>>p0;
    double p[1000001];
	fill(p+2, p+n+1, 1.0);
	for(int i=2; i<=n; i++){
		for(int j=2*i; j<=n; j+=i){
			p[j]*=(1.0-p0);
		}
	}
	double ans=0;
	for(int i=2; i<=n; i++) ans+=p[i];
	printf("%.7lf\n", ans);
    return 0;
}
0