結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 tatt61880tatt61880
提出日時 2021-03-23 23:43:37
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 66 ms / 1,000 ms
コード長 564 bytes
コンパイル時間 3,077 ms
コンパイル使用メモリ 150,276 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2023-10-14 17:55:09
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
8,436 KB
testcase_01 AC 61 ms
8,260 KB
testcase_02 AC 61 ms
8,288 KB
testcase_03 AC 61 ms
8,340 KB
testcase_04 AC 61 ms
8,440 KB
testcase_05 AC 61 ms
8,408 KB
testcase_06 AC 62 ms
8,200 KB
testcase_07 AC 63 ms
8,460 KB
testcase_08 AC 62 ms
8,296 KB
testcase_09 AC 60 ms
8,284 KB
testcase_10 AC 62 ms
8,240 KB
testcase_11 AC 62 ms
8,500 KB
testcase_12 AC 62 ms
8,304 KB
testcase_13 AC 61 ms
8,424 KB
testcase_14 AC 62 ms
8,440 KB
testcase_15 AC 61 ms
8,204 KB
testcase_16 AC 61 ms
8,340 KB
testcase_17 AC 62 ms
8,104 KB
testcase_18 AC 61 ms
8,204 KB
testcase_19 AC 63 ms
8,260 KB
testcase_20 AC 61 ms
8,352 KB
testcase_21 AC 62 ms
8,300 KB
testcase_22 AC 63 ms
8,316 KB
testcase_23 AC 63 ms
8,332 KB
testcase_24 AC 63 ms
8,228 KB
testcase_25 AC 62 ms
8,220 KB
testcase_26 AC 62 ms
8,232 KB
testcase_27 AC 62 ms
8,216 KB
testcase_28 AC 61 ms
8,368 KB
testcase_29 AC 62 ms
8,528 KB
testcase_30 AC 62 ms
8,340 KB
testcase_31 AC 63 ms
8,284 KB
testcase_32 AC 66 ms
8,156 KB
testcase_33 AC 63 ms
8,260 KB
testcase_34 AC 61 ms
8,304 KB
testcase_35 AC 61 ms
8,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt() - 1
	var l: int :: cui@inputInt()
	
	var isPrime: []bool :: sieve(5000000)
	var ans: int :: 0
	for p(2, 5000000)
		if(isPrime[p])
			do ans :+ [0, l - p * n + 1].max()
		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