結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 16 ms
5,492 KB
testcase_02 AC 16 ms
5,392 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 32 ms
13,256 KB
testcase_05 AC 64 ms
20,972 KB
testcase_06 AC 62 ms
21,020 KB
testcase_07 AC 62 ms
21,156 KB
testcase_08 AC 18 ms
6,596 KB
testcase_09 AC 18 ms
6,596 KB
testcase_10 AC 60 ms
21,216 KB
testcase_11 AC 29 ms
12,316 KB
testcase_12 AC 67 ms
20,448 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 16 ms
5,516 KB
testcase_15 AC 16 ms
5,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var k: int :: cui@inputInt()
	if(k = 1)
		do cui@print("\{n - 1}\n")
		ret
	end if
	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