結果

問題 No.144 エラトステネスのざる
ユーザー furafyfurafy
提出日時 2015-03-08 18:11:28
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 24,940 KB
実行使用メモリ 13,664 KB
最終ジャッジ日時 2023-09-06 21:54:13
合計ジャッジ時間 2,227 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 32 ms
12,444 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 95 ms
12,932 KB
testcase_19 AC 32 ms
9,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void) {
	int n, x, i;
	float p, mean = 0;
	float list_of_koho[n+1];
	float list_of_sosu[n+1];

	scanf("%d %f", &n, &p);
	for (i = 2; i <= n; i++) {
		list_of_koho[i] = 1;
		list_of_sosu[i] = 0;
	}
	for (x = 2; x <= n; x++) {
		list_of_sosu[x] = list_of_koho[x];
		list_of_koho[x] = 0;
		for (i = 2; x*i <= n; i++)
			list_of_koho[x*i] -= list_of_koho[x*i] * p;
	}
	for (i = 2; i <= n; i++)
		mean += list_of_sosu[i];
	printf("%f\n", mean);

	return 0;
}
0