結果

問題 No.6 使いものにならないハッシュ
ユーザー Kude
提出日時 2020-09-03 07:21:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 78,420 KB
最終ジャッジ日時 2024-09-16 16:59:00
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
n = int(input())
sieve = [True] * (n + 1)
primes = []
for p in range(2, n + 1):
    if sieve[p]:
        if p >= k:
            primes.append(p)
        for i in range(p * p, n + 1, p):
            sieve[i] = False
seen = [False] * 10
mx = 0
now = 0
from collections import deque
q = deque()
for p in primes:
    po = p
    while p >= 10:
        p = sum(map(int, str(p)))
    while seen[p]:
        i, _ = q.popleft()
        seen[i] = False
        now -= 1
    q.append((p, po))
    seen[p] = True
    now += 1
    if now >= mx:
        ans = q[0][1]
        mx = now
print(ans)
0