結果

問題 No.144 エラトステネスのざる
ユーザー Lepton_s
提出日時 2015-02-11 00:07:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 55,220 KB
実行使用メモリ 15,504 KB
最終ジャッジ日時 2024-06-23 18:26:00
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define N 1000100
int p[N];
double r[N];

int main(){
	int n;
	double q;
	cin>>n>>q;
	for(int i = 2; i <= n/2; i++)
		for(int j = i*2; j <= n; j+=i)
			p[j]++;
	r[0] = 1.0;
	for(int i = 1; i <= n; i++) r[i] = r[i-1]*(1.0-q);
	double res = 0;
	for(int i = 2; i <= n; i++)
		res += r[p[i]];
	cout<<res<<endl;
	return 0;
}
0