結果

問題 No.144 エラトステネスのざる
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-08-25 16:32:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 64,364 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-11-08 02:22:15
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[1000010];

int main(void){
	int n; double p;
	cin >> n >> p;
	for (int i = 2; i <= n; ++i){//約数i
		for (int j = i * 2; j <= n; j += i){
			a[j]++;
		}
	}
	double e = 0;
	for (int i = 2; i <= n; ++i){
		e += pow((1 - p), a[i]);
	}
	printf("%.10f\n", e);
	return 0;
}
0