結果

問題 No.6 使いものにならないハッシュ
ユーザー snnekosnneko
提出日時 2019-03-18 18:22:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,787 ms / 5,000 ms
コード長 1,009 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 30,580 KB
最終ジャッジ日時 2023-10-14 23:15:03
合計ジャッジ時間 57,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
29,528 KB
testcase_01 AC 126 ms
29,608 KB
testcase_02 AC 2,787 ms
30,580 KB
testcase_03 AC 448 ms
29,620 KB
testcase_04 AC 870 ms
29,800 KB
testcase_05 AC 692 ms
29,788 KB
testcase_06 AC 1,718 ms
30,148 KB
testcase_07 AC 1,633 ms
30,160 KB
testcase_08 AC 1,765 ms
30,168 KB
testcase_09 AC 2,623 ms
30,216 KB
testcase_10 AC 127 ms
29,544 KB
testcase_11 AC 434 ms
29,684 KB
testcase_12 AC 1,714 ms
30,148 KB
testcase_13 AC 2,286 ms
30,204 KB
testcase_14 AC 2,410 ms
30,200 KB
testcase_15 AC 1,492 ms
30,116 KB
testcase_16 AC 2,266 ms
30,180 KB
testcase_17 AC 2,617 ms
30,356 KB
testcase_18 AC 2,607 ms
30,520 KB
testcase_19 AC 2,511 ms
30,372 KB
testcase_20 AC 1,985 ms
30,304 KB
testcase_21 AC 283 ms
29,668 KB
testcase_22 AC 2,309 ms
30,316 KB
testcase_23 AC 1,711 ms
30,216 KB
testcase_24 AC 2,158 ms
30,336 KB
testcase_25 AC 1,627 ms
30,132 KB
testcase_26 AC 2,414 ms
30,392 KB
testcase_27 AC 2,258 ms
30,340 KB
testcase_28 AC 1,157 ms
30,060 KB
testcase_29 AC 2,483 ms
30,400 KB
testcase_30 AC 2,072 ms
30,396 KB
testcase_31 AC 2,112 ms
30,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# #S = list(map(int, input().split()))
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:
        ans = k % 10
    else:
        while k >= 10:
            ans = 0
            while k >= 10:
                ans += k % 10
                k //= 10
            ans += k % 10
            k = ans
    hash_list.append(ans)

result = 0
max_size = 0
result_list = []
for i, j in enumerate(hash_list):
    while True:
        if j in result_list:
            result_list.pop(0)
            continue
        else:
            result_list.append(j)
            break
    if max_size <= len(result_list):
        max_size = len(result_list)
        result = i - (len(result_list) - 1)

print (k_list[result])
0