結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2024-02-25 22:31:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 870 bytes |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 104,832 KB |
| 最終ジャッジ日時 | 2024-09-29 11:24:15 |
| 合計ジャッジ時間 | 4,571 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 RE * 1 |
ソースコード
def seachPrimeNum(N):
if N == 2:
return []
max = int(N ** 0.5)
seachList = [i for i in range(2, N + 1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
from bisect import bisect_left
K = int(input())
N = int(input())
PL = seachPrimeNum(N)
k = bisect_left(PL, K)
X = [-1] * 10
def f(x):
while x >= 10:
ret = 0
while x > 0:
ret += x % 10
x //= 10
x = ret
return x
n = len(PL)
i = n - 1
tmp2 = 0
tmp = n - 1
while i >= k:
h = f(PL[i])
if X[h] != -1:
if tmp >= X[h]:
tmp = X[h] - 1
X[h] = i
if tmp2 < tmp - i + 1:
tmp2 = tmp - i + 1
ans = PL[i]
i -= 1
print(ans)
ntuda