結果

問題 No.144 エラトステネスのざる
ユーザー furafyfurafy
提出日時 2015-03-08 18:20:48
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 25,252 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2023-09-06 21:55:32
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, x, i;
	float p, mean = 0;
	float *list_of_koho;
	float *list_of_sosu;

	scanf("%d %f", &n, &p);
	list_of_koho = (float *)malloc( sizeof( float ) * (n+1) );
	list_of_sosu = (float *)malloc( sizeof( float ) * (n+1) );
	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