結果

問題 No.3079 アルベド
ユーザー 👑 tatt61880tatt61880
提出日時 2021-04-01 23:14:58
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 151,804 KB
実行使用メモリ 4,660 KB
最終ジャッジ日時 2023-10-14 18:13:21
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,364 KB
testcase_01 AC 117 ms
4,624 KB
testcase_02 AC 72 ms
4,368 KB
testcase_03 AC 49 ms
4,392 KB
testcase_04 AC 90 ms
4,660 KB
testcase_05 AC 66 ms
4,404 KB
testcase_06 AC 82 ms
4,380 KB
testcase_07 AC 17 ms
4,496 KB
testcase_08 AC 24 ms
4,352 KB
testcase_09 AC 63 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	const max: int :: 100000
	var isPrime: []bool :: sieve(max)
	var cum: []int :: #[max + 1]int
	for i(1, max)
		do cum[i] :: cum[i - 1] + (isPrime[i] ?(1, 0))
	end for
	var t: int :: cui@inputInt()
	for(1, t)
		var n: int :: cui@inputInt()
		do cui@print("\{cum[n]}\n")
	end for
	
	func sieve(n: int): []bool
		if(n < 2)
			ret[false].repeat(n + 1)
		end if
		var isPrime: []bool :: [true].repeat(n + 1)
		do isPrime[0] :: false
		do isPrime[1] :: false
		for i(2, n)
			if(isPrime[i])
				var j: int :: i * i
				while(j <= n)
					do isPrime[j] :: false
					do j :+ i
				end while
			end if
		end for
		ret isPrime
	end func
end func
0