結果

問題 No.106 素数が嫌い!2
ユーザー 👑 tatt61880tatt61880
提出日時 2021-03-20 19:27:48
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 150,956 KB
実行使用メモリ 21,264 KB
最終ジャッジ日時 2023-10-14 17:45:14
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 14 ms
5,508 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 36 ms
21,192 KB
testcase_07 AC 38 ms
21,256 KB
testcase_08 WA -
testcase_09 AC 16 ms
6,532 KB
testcase_10 AC 35 ms
20,912 KB
testcase_11 AC 23 ms
12,156 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 14 ms
5,476 KB
testcase_15 AC 15 ms
5,612 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 i: int :: 2
	var isPrime: []bool :: sieve(2000000)
	while loop(i * i <= n)
		if(isPrime[i])
			var x: int :: i
			while(x <= n)
				do a[x] :+ 1
				do x :+ i
			end while
		end if
		do i :+ 1
	end while
	
	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
	
	var ans: int :: 0
	for j(2, n)
		if(a[j] >= k)
			do ans :+ 1
		end if
	end for
	do cui@print("\{ans}\n")
end func
0