結果

問題 No.106 素数が嫌い!2
ユーザー 👑 tatt61880tatt61880
提出日時 2021-03-20 19:32:42
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 681 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 152,068 KB
実行使用メモリ 21,192 KB
最終ジャッジ日時 2023-10-14 17:45:22
合計ジャッジ時間 3,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
13,252 KB
testcase_01 AC 16 ms
5,568 KB
testcase_02 AC 15 ms
5,460 KB
testcase_03 AC 16 ms
5,484 KB
testcase_04 AC 29 ms
13,124 KB
testcase_05 AC 52 ms
21,192 KB
testcase_06 AC 49 ms
21,012 KB
testcase_07 AC 49 ms
21,168 KB
testcase_08 AC 18 ms
6,396 KB
testcase_09 AC 18 ms
6,448 KB
testcase_10 AC 49 ms
21,172 KB
testcase_11 AC 27 ms
12,208 KB
testcase_12 AC 51 ms
20,600 KB
testcase_13 AC 15 ms
5,544 KB
testcase_14 AC 16 ms
5,536 KB
testcase_15 AC 15 ms
5,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var k: int :: cui@inputInt()
	var cnt: []int :: #[n + 1]int
	var isPrime: []bool :: sieve(2000000)
	for i(2, n)
		if(isPrime[i])
			var x: int :: i
			while(x <= n)
				do cnt[x] :+ 1
				do x :+ i
			end while
		end if
	end for
	var ans: int :: 0
	for j(2, n)
		do ans :+ cnt[j] >= k ?(1, 0)
	end for
	do cui@print("\{ans}\n")
	
	func sieve(n: int): []bool
		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