結果

問題 No.6 使いものにならないハッシュ
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-05-22 18:16:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-04-18 23:05:30
合計ジャッジ時間 3,378 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 39 ms
52,224 KB
testcase_02 AC 66 ms
67,328 KB
testcase_03 WA -
testcase_04 AC 69 ms
71,552 KB
testcase_05 AC 72 ms
72,704 KB
testcase_06 WA -
testcase_07 AC 75 ms
73,472 KB
testcase_08 AC 71 ms
73,728 KB
testcase_09 WA -
testcase_10 AC 37 ms
52,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 77 ms
76,116 KB
testcase_20 AC 74 ms
74,752 KB
testcase_21 AC 65 ms
67,072 KB
testcase_22 WA -
testcase_23 AC 73 ms
75,104 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 80 ms
77,312 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
		for j in range(10):
			rem = bkt[h]
			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