結果

問題 No.6 使いものにならないハッシュ
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-05-20 10:59:36
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 193 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-10-14 23:11:37
合計ジャッジ時間 4,634 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,816 KB
testcase_01 AC 16 ms
7,804 KB
testcase_02 AC 193 ms
10,696 KB
testcase_03 AC 45 ms
8,764 KB
testcase_04 AC 58 ms
9,040 KB
testcase_05 AC 69 ms
9,044 KB
testcase_06 AC 114 ms
9,676 KB
testcase_07 AC 78 ms
9,548 KB
testcase_08 AC 102 ms
9,704 KB
testcase_09 AC 74 ms
9,628 KB
testcase_10 AC 16 ms
7,804 KB
testcase_11 AC 50 ms
8,780 KB
testcase_12 AC 136 ms
9,916 KB
testcase_13 AC 63 ms
9,512 KB
testcase_14 AC 69 ms
9,656 KB
testcase_15 AC 110 ms
9,448 KB
testcase_16 AC 91 ms
9,856 KB
testcase_17 AC 143 ms
10,388 KB
testcase_18 AC 184 ms
10,392 KB
testcase_19 AC 142 ms
10,240 KB
testcase_20 AC 127 ms
9,744 KB
testcase_21 AC 33 ms
8,436 KB
testcase_22 AC 132 ms
10,044 KB
testcase_23 AC 128 ms
9,928 KB
testcase_24 AC 130 ms
9,912 KB
testcase_25 AC 84 ms
9,520 KB
testcase_26 AC 152 ms
10,280 KB
testcase_27 AC 121 ms
9,932 KB
testcase_28 AC 87 ms
9,224 KB
testcase_29 AC 162 ms
10,440 KB
testcase_30 AC 147 ms
10,136 KB
testcase_31 AC 132 ms
10,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
n = int(input())
siv = [True]*(n+1)
siv[0] = siv[1] = False
for i in range(2, int(n**0.5)+2):
    if not siv[i]:
        continue
    for j in range(i*2, n+1, i):
        siv[j] = False
prm = [i for i in range(k, n+1) if siv[i]]
def hsh(x):
    x = sum(map(int, str(x)))
    if x >= 10:
        return hsh(x)
    return x
vis = set()
mx = res = beg = 0
end = -1
while end < len(prm)-1:
    h = hsh(prm[end+1])
    if h in vis:
        vis.remove(hsh(prm[beg]))
        beg += 1
    else:
        vis.add(h)
        end += 1
        if len(vis) >= mx:
            mx = len(vis)
            res = prm[beg]
print(res)
0