結果

問題 No.144 エラトステネスのざる
ユーザー 👑 tatt61880tatt61880
提出日時 2021-08-11 13:16:58
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 3,177 ms
コンパイル使用メモリ 147,028 KB
実行使用メモリ 11,468 KB
最終ジャッジ日時 2023-10-25 04:18:04
合計ジャッジ時間 4,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 42 ms
11,408 KB
testcase_14 AC 42 ms
11,468 KB
testcase_15 AC 41 ms
11,468 KB
testcase_16 AC 42 ms
11,468 KB
testcase_17 AC 41 ms
11,468 KB
testcase_18 AC 45 ms
11,468 KB
testcase_19 AC 41 ms
11,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var p: float :: cui@inputFloat()
	var ps: []float :: @sieve(n, p)
	var ans: float :: 0.0
	for i(2, n)
		do ans :+ ps[i]
	end for
	do cui@print("\{ans}\n")
end func

func sieve(n: int, p: float): []float
	if(n < 2)
		ret [0.0].repeat(n + 1)
	end if
	var res: []float :: [1.0].repeat(n + 1)
	for i(2, n)
		var j: int :: 2 * i
		while(j <= n)
			do res[j] :* 1.0 - p
			do j :+ i
		end while
	end for
	ret res
end func
0