結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-12 21:04:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 5,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 81,716 KB |
| 実行使用メモリ | 77,312 KB |
| 最終ジャッジ日時 | 2024-06-28 16:47:40 |
| 合計ジャッジ時間 | 4,354 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
k = int(input())
n = int(input())
primes = []
l = []
for i in range(2,n+1):
check = True
for p in primes:
if p**2 > i:
break
if i%p == 0:
check = False
break
if check:
primes.append(i)
if k <= i <= n:
l.append(i)
def hash(x):
now = x
while True:
now = sum([int(i) for i in str(now)])
if now < 10:
return now
count = [0]*10
now = 0
ans = []
hashl = [hash(i) for i in l]
for i,h in enumerate(hashl):
while now < len(l) and count[hashl[now]] == 0:
count[hashl[now]] += 1
now += 1
ans.append(now-i)
count[hashl[i]] -= 1
m = max(ans)
for i in range(len(ans))[::-1]:
if ans[i] == m:
print(l[i])
exit()