結果

問題 No.6 使いものにならないハッシュ
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-05-22 18:19:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 73,344 KB
最終ジャッジ日時 2024-04-18 23:08:22
合計ジャッジ時間 3,294 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 45 ms
52,096 KB
testcase_02 AC 65 ms
67,200 KB
testcase_03 AC 55 ms
65,408 KB
testcase_04 AC 58 ms
66,816 KB
testcase_05 AC 59 ms
66,944 KB
testcase_06 AC 65 ms
69,760 KB
testcase_07 AC 66 ms
67,712 KB
testcase_08 AC 67 ms
69,632 KB
testcase_09 AC 65 ms
67,584 KB
testcase_10 AC 38 ms
52,480 KB
testcase_11 AC 58 ms
65,664 KB
testcase_12 AC 70 ms
71,808 KB
testcase_13 AC 59 ms
66,304 KB
testcase_14 AC 61 ms
66,304 KB
testcase_15 AC 66 ms
69,888 KB
testcase_16 AC 65 ms
68,608 KB
testcase_17 AC 72 ms
71,040 KB
testcase_18 AC 75 ms
73,088 KB
testcase_19 AC 69 ms
70,936 KB
testcase_20 AC 67 ms
70,528 KB
testcase_21 AC 55 ms
64,768 KB
testcase_22 AC 68 ms
70,784 KB
testcase_23 AC 70 ms
71,040 KB
testcase_24 AC 70 ms
70,528 KB
testcase_25 AC 61 ms
67,712 KB
testcase_26 AC 74 ms
72,320 KB
testcase_27 AC 68 ms
70,144 KB
testcase_28 AC 62 ms
67,968 KB
testcase_29 AC 74 ms
73,344 KB
testcase_30 AC 71 ms
71,808 KB
testcase_31 AC 70 ms
70,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stderr

K = int(input())
N = int(input())

isprime = [True] * (N + 1)
isprime[0] = isprime[1] = False
for i in range(2, N + 1):
	if isprime[i]:
		for j in range(i * 2, N + 1, i):
			isprime[j] = False

maxlen = len = 0
bkt = [-1] * 10
ans = 0

for i in range(K, N + 1):
	if not isprime[i]:
		continue
	h = i % 9
	if bkt[h] != -1:
		rem = bkt[h]
		for j in range(10):
			if 0 <= bkt[j] <= rem:
				bkt[j] = -1
				len -= 1
	bkt[h] = i
	len += 1
	if len >= maxlen:
		ans = min(v for v in bkt if v >= 0)
		maxlen = len

print(ans)
0