結果

問題 No.6 使いものにならないハッシュ
ユーザー snnekosnneko
提出日時 2019-03-18 18:49:52
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 2,508 ms / 5,000 ms
コード長 864 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 30,516 KB
最終ジャッジ日時 2023-10-14 23:20:10
合計ジャッジ時間 51,931 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
29,616 KB
testcase_01 AC 125 ms
29,544 KB
testcase_02 AC 2,494 ms
30,516 KB
testcase_03 AC 435 ms
29,776 KB
testcase_04 AC 846 ms
29,848 KB
testcase_05 AC 636 ms
29,972 KB
testcase_06 AC 1,632 ms
30,180 KB
testcase_07 AC 1,413 ms
30,044 KB
testcase_08 AC 1,717 ms
30,156 KB
testcase_09 AC 2,508 ms
30,228 KB
testcase_10 AC 122 ms
29,600 KB
testcase_11 AC 400 ms
29,660 KB
testcase_12 AC 1,604 ms
30,316 KB
testcase_13 AC 2,095 ms
30,192 KB
testcase_14 AC 2,238 ms
30,180 KB
testcase_15 AC 1,430 ms
30,052 KB
testcase_16 AC 2,226 ms
30,284 KB
testcase_17 AC 2,431 ms
30,336 KB
testcase_18 AC 2,441 ms
30,488 KB
testcase_19 AC 2,348 ms
30,376 KB
testcase_20 AC 1,875 ms
30,436 KB
testcase_21 AC 270 ms
29,700 KB
testcase_22 AC 2,140 ms
30,304 KB
testcase_23 AC 1,612 ms
30,196 KB
testcase_24 AC 1,882 ms
30,368 KB
testcase_25 AC 1,481 ms
30,116 KB
testcase_26 AC 2,202 ms
30,400 KB
testcase_27 AC 2,182 ms
30,360 KB
testcase_28 AC 1,008 ms
30,048 KB
testcase_29 AC 2,214 ms
30,428 KB
testcase_30 AC 1,932 ms
30,316 KB
testcase_31 AC 1,924 ms
30,304 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 = [0] * len(k_list)
for i, k in enumerate(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[i] = 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