結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
13,140 KB
testcase_01 AC 15 ms
5,568 KB
testcase_02 AC 15 ms
5,672 KB
testcase_03 AC 15 ms
5,460 KB
testcase_04 AC 31 ms
13,252 KB
testcase_05 AC 49 ms
21,324 KB
testcase_06 AC 45 ms
21,296 KB
testcase_07 AC 45 ms
21,080 KB
testcase_08 AC 17 ms
6,664 KB
testcase_09 AC 16 ms
6,460 KB
testcase_10 AC 45 ms
21,224 KB
testcase_11 AC 28 ms
12,300 KB
testcase_12 AC 54 ms
20,360 KB
testcase_13 AC 16 ms
5,536 KB
testcase_14 AC 15 ms
5,488 KB
testcase_15 AC 15 ms
5,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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