結果

問題 No.144 エラトステネスのざる
ユーザー 👑 tatt61880tatt61880
提出日時 2021-04-03 12:12:47
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 151,228 KB
実行使用メモリ 11,532 KB
最終ジャッジ日時 2023-10-14 18:14:05
合計ジャッジ時間 3,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 51 ms
11,440 KB
testcase_14 AC 54 ms
11,316 KB
testcase_15 AC 54 ms
11,452 KB
testcase_16 AC 52 ms
11,308 KB
testcase_17 AC 51 ms
11,528 KB
testcase_18 AC 56 ms
11,468 KB
testcase_19 AC 52 ms
11,532 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")
	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
end func
0