結果

問題 No.6 使いものにならないハッシュ
ユーザー ああいいああいい
提出日時 2022-01-09 23:43:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2024-04-26 19:57:27
合計ジャッジ時間 4,146 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,712 KB
testcase_01 AC 38 ms
51,968 KB
testcase_02 AC 95 ms
77,824 KB
testcase_03 AC 78 ms
76,544 KB
testcase_04 AC 81 ms
76,544 KB
testcase_05 AC 96 ms
76,928 KB
testcase_06 AC 91 ms
77,184 KB
testcase_07 AC 89 ms
77,312 KB
testcase_08 AC 93 ms
77,184 KB
testcase_09 AC 82 ms
77,440 KB
testcase_10 AC 40 ms
51,840 KB
testcase_11 AC 91 ms
76,544 KB
testcase_12 AC 107 ms
77,440 KB
testcase_13 AC 72 ms
72,320 KB
testcase_14 AC 80 ms
77,568 KB
testcase_15 AC 104 ms
77,440 KB
testcase_16 AC 95 ms
77,696 KB
testcase_17 AC 106 ms
78,080 KB
testcase_18 AC 98 ms
77,824 KB
testcase_19 AC 94 ms
77,568 KB
testcase_20 AC 98 ms
77,568 KB
testcase_21 AC 78 ms
75,904 KB
testcase_22 AC 92 ms
77,952 KB
testcase_23 AC 93 ms
77,312 KB
testcase_24 AC 98 ms
77,696 KB
testcase_25 AC 84 ms
77,440 KB
testcase_26 AC 96 ms
77,696 KB
testcase_27 AC 94 ms
77,568 KB
testcase_28 AC 87 ms
76,800 KB
testcase_29 AC 106 ms
77,824 KB
testcase_30 AC 106 ms
77,696 KB
testcase_31 AC 96 ms
77,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
N = int(input())

dat = [0] * (N + 1)
prime = []
for i in range(2,N+1):
    if dat[i] == 0:
        for j in range(i * 2,N+1,i):
            dat[j] = 1
        if i >= K:
            prime.append(i)
def hash(x):
    if x <= 9:return x
    a = 0
    while x:
        a += x % 10
        x //= 10
    return hash(a)
N = len(prime)
right = 0
s = set()
_max = 0
index = -1
for left in range(N):
    while right < N and hash(prime[right]) not in s:
        s.add(hash(prime[right]))
        right += 1
    if right - left >= _max:
        _max = right - left
        index = prime[left]
    s.remove(hash(prime[left]))
print(index)
0