結果

問題 No.144 エラトステネスのざる
ユーザー Lepton_sLepton_s
提出日時 2015-02-11 00:07:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 52,060 KB
実行使用メモリ 15,384 KB
最終ジャッジ日時 2023-09-05 23:06:14
合計ジャッジ時間 1,721 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,752 KB
testcase_01 AC 2 ms
5,572 KB
testcase_02 AC 2 ms
5,708 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,504 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
5,576 KB
testcase_07 AC 2 ms
5,716 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,588 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,716 KB
testcase_12 AC 2 ms
5,692 KB
testcase_13 AC 34 ms
15,284 KB
testcase_14 AC 34 ms
15,380 KB
testcase_15 WA -
testcase_16 AC 36 ms
15,224 KB
testcase_17 AC 36 ms
15,256 KB
testcase_18 AC 35 ms
15,244 KB
testcase_19 AC 35 ms
15,384 KB
権限があれば一括ダウンロードができます

ソースコード

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