結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 tatt61880tatt61880
提出日時 2021-08-11 22:39:01
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 55 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 4,851 ms
コンパイル使用メモリ 147,124 KB
実行使用メモリ 13,552 KB
最終ジャッジ日時 2023-10-26 00:35:57
合計ジャッジ時間 6,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 6 ms
4,712 KB
testcase_20 AC 17 ms
6,560 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 29 ms
8,672 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 14 ms
6,032 KB
testcase_33 AC 55 ms
13,552 KB
testcase_34 AC 54 ms
13,552 KB
testcase_35 AC 25 ms
8,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt() - 1
	var l: int :: cui@inputInt()
	
	var max: int :: l / n
	var isPrime: []bool :: @sieve(max)
	var ans: int :: 0
	for p(2, max)
		if(isPrime[p])
			do ans :+ l - p * n + 1
		end if
	end for
	do cui@print("\{ans}\n")
end func

func sieve(n: int): []bool
	if(n < 2)
		ret [false].repeat(n + 1)
	end if
	var isPrime: []bool :: [false, false] ~ [true].repeat(n - 1)
	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
0