結果

問題 No.6 使いものにならないハッシュ
コンテスト
ユーザー snneko
提出日時 2019-03-18 18:43:59
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 2,889 ms / 5,000 ms
+ 693µs
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 306 ms
コンパイル使用メモリ 21,540 KB
実行使用メモリ 35,496 KB
最終ジャッジ日時 2026-08-28 23:38:20
合計ジャッジ時間 65,715 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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