結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-09 22:56:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 5,000 ms |
| コード長 | 972 bytes |
| コンパイル時間 | 257 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 76,100 KB |
| 最終ジャッジ日時 | 2024-09-14 00:25:08 |
| 合計ジャッジ時間 | 3,943 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
IsPrime = [True for _ in range(2 * 10**5 + 1)]
IsPrime[0] = IsPrime[1] = False
for i in range(2, 2 * 10**5 + 1):
if IsPrime[i]:
for j in range(i + i, 2 * 10**5 + 1, i):
IsPrime[j] = False
n = int(input())
k = int(input())
from collections import defaultdict
Prime = []
L = []
for i in range(n, k + 1):
if IsPrime[i]:
Prime.append(i)
ic = i
while ic > 9:
temp = 0
while ic != 0:
temp += ic % 10
ic //= 10
ic = temp
L.append(ic)
m = len(Prime)
counter = defaultdict(int)
DP = [0 for _ in range(m)]
right = 0
length = 0
ans = 0
for left in range(m):
while right < m:
counter[L[right]] += 1
if counter[L[right]] == 2:
counter[L[right]] -= 1
break
right += 1
if right - left >= length:
length = right - left
ans = max(ans, Prime[left])
counter[L[left]] -= 1
print(ans)