結果

問題 No.6 使いものにならないハッシュ
ユーザー snnekosnneko
提出日時 2019-03-18 18:43:59
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 2,723 ms / 5,000 ms
コード長 842 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 30,544 KB
最終ジャッジ日時 2023-10-14 23:16:02
合計ジャッジ時間 58,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,644 KB
testcase_01 AC 139 ms
29,552 KB
testcase_02 AC 2,723 ms
30,544 KB
testcase_03 AC 445 ms
29,720 KB
testcase_04 AC 895 ms
29,788 KB
testcase_05 AC 686 ms
29,744 KB
testcase_06 AC 1,700 ms
30,124 KB
testcase_07 AC 1,660 ms
29,996 KB
testcase_08 AC 1,789 ms
30,156 KB
testcase_09 AC 2,697 ms
30,308 KB
testcase_10 AC 132 ms
29,480 KB
testcase_11 AC 432 ms
29,748 KB
testcase_12 AC 1,736 ms
30,260 KB
testcase_13 AC 2,376 ms
30,056 KB
testcase_14 AC 2,362 ms
30,216 KB
testcase_15 AC 1,458 ms
30,160 KB
testcase_16 AC 2,293 ms
30,216 KB
testcase_17 AC 2,667 ms
30,352 KB
testcase_18 AC 2,693 ms
30,468 KB
testcase_19 AC 2,553 ms
30,348 KB
testcase_20 AC 1,966 ms
30,288 KB
testcase_21 AC 294 ms
29,576 KB
testcase_22 AC 2,303 ms
30,400 KB
testcase_23 AC 1,767 ms
30,288 KB
testcase_24 AC 2,080 ms
30,420 KB
testcase_25 AC 1,684 ms
30,208 KB
testcase_26 AC 2,521 ms
30,496 KB
testcase_27 AC 2,267 ms
30,240 KB
testcase_28 AC 1,132 ms
30,048 KB
testcase_29 AC 2,489 ms
30,500 KB
testcase_30 AC 2,071 ms
30,348 KB
testcase_31 AC 2,155 ms
30,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
K = int(input())
N = int(input())

p_list = []
for i in range(2, N+1):
    flg = 0
    for p in p_list:
        if np.sqrt(i) < p:
            break
        if i % p == 0:
            flg = 1
            break
    if flg == 0:
        p_list.append(i)

k_list = [p for p in p_list if p >= K]

hash_list = list()
for k in k_list:
    if k < 10:
        hash = k % 10
    else:
        while k >= 10:
            hash = 0
            while k >= 10:
                hash += k % 10
                k //= 10
            hash += k % 10
            k = hash
    hash_list.append(hash)

result = 0
max_size = 0
j = 0
for i in range(len(hash_list)):
    while hash_list[i] in hash_list[j:i]:
        j += 1
    if max_size <= len(hash_list[j:i+1]):
        max_size = len(hash_list[j:i+1])
        result = j

print (k_list[result])
0