結果

問題 No.6 使いものにならないハッシュ
ユーザー KudeKude
提出日時 2020-09-03 07:21:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 79,760 KB
最終ジャッジ日時 2023-10-14 23:26:58
合計ジャッジ時間 5,699 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,524 KB
testcase_01 AC 93 ms
71,488 KB
testcase_02 AC 142 ms
79,452 KB
testcase_03 AC 130 ms
78,796 KB
testcase_04 AC 128 ms
78,368 KB
testcase_05 AC 132 ms
79,036 KB
testcase_06 AC 136 ms
79,088 KB
testcase_07 AC 133 ms
78,872 KB
testcase_08 AC 137 ms
79,324 KB
testcase_09 AC 125 ms
79,168 KB
testcase_10 AC 92 ms
71,556 KB
testcase_11 AC 143 ms
78,344 KB
testcase_12 AC 129 ms
79,596 KB
testcase_13 AC 121 ms
78,928 KB
testcase_14 AC 128 ms
78,836 KB
testcase_15 AC 125 ms
78,496 KB
testcase_16 AC 123 ms
79,168 KB
testcase_17 AC 137 ms
79,716 KB
testcase_18 AC 133 ms
79,760 KB
testcase_19 AC 134 ms
79,260 KB
testcase_20 AC 130 ms
79,080 KB
testcase_21 AC 125 ms
78,388 KB
testcase_22 AC 130 ms
79,084 KB
testcase_23 AC 129 ms
78,972 KB
testcase_24 AC 133 ms
79,128 KB
testcase_25 AC 129 ms
78,952 KB
testcase_26 AC 132 ms
79,484 KB
testcase_27 AC 129 ms
79,228 KB
testcase_28 AC 125 ms
78,520 KB
testcase_29 AC 131 ms
79,600 KB
testcase_30 AC 135 ms
79,048 KB
testcase_31 AC 126 ms
79,312 KB
権限があれば一括ダウンロードができます

ソースコード

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