結果

問題 No.6 使いものにならないハッシュ
ユーザー momoyuumomoyuu
提出日時 2022-08-03 00:15:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 999 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2023-10-01 00:54:33
合計ジャッジ時間 5,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,124 KB
testcase_01 AC 73 ms
71,088 KB
testcase_02 AC 130 ms
78,752 KB
testcase_03 AC 103 ms
77,620 KB
testcase_04 AC 102 ms
77,508 KB
testcase_05 AC 105 ms
77,244 KB
testcase_06 AC 115 ms
78,304 KB
testcase_07 AC 108 ms
77,840 KB
testcase_08 AC 114 ms
78,364 KB
testcase_09 AC 105 ms
78,604 KB
testcase_10 AC 72 ms
71,096 KB
testcase_11 AC 102 ms
77,272 KB
testcase_12 AC 124 ms
78,320 KB
testcase_13 AC 103 ms
78,720 KB
testcase_14 AC 106 ms
78,396 KB
testcase_15 AC 120 ms
78,224 KB
testcase_16 AC 110 ms
78,368 KB
testcase_17 AC 126 ms
78,848 KB
testcase_18 AC 129 ms
78,444 KB
testcase_19 AC 124 ms
78,828 KB
testcase_20 AC 124 ms
78,180 KB
testcase_21 AC 99 ms
77,512 KB
testcase_22 AC 120 ms
78,584 KB
testcase_23 AC 126 ms
78,088 KB
testcase_24 AC 126 ms
78,376 KB
testcase_25 AC 111 ms
77,980 KB
testcase_26 AC 128 ms
78,720 KB
testcase_27 AC 120 ms
78,424 KB
testcase_28 AC 113 ms
77,492 KB
testcase_29 AC 132 ms
78,324 KB
testcase_30 AC 128 ms
78,456 KB
testcase_31 AC 124 ms
78,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
N = int(input())

def calc(n):
    now = n
    while now >= 10:
        a = str(now)
        now = 0
        for i in a:
            now += int(i)
    return now

def era(n):
    """
    n以下の素数をリストで小さい順に返す。
    O(nlognlogn)
    """
    s = [1 for _ in range(n+1)]
    for i in range(2,n+1):
        if s[i] == 0:
            continue
        j = 2
        while j * i <= n:
            s[j*i] = 0
            j += 1
    l = []
    for i in range(2,n+1):
        if s[i] == 1:
            l.append(i)
    return l

l = era(N)
now = 0
li = []
nn = 0
for i in range(len(l)):
    if l[i] < K:
        continue
    s = set()
    k = 0
    for j in range(10):
        ni = i + j
        k = j
        if ni >= len(l):
            break
        a = calc(l[ni])
        if a in s:
            break
        s.add(a)
    if now <= k:
        now = k
        nn = l[i]
        li = []
        for j in range(now):
            li.append(l[i + j])

print(nn)
0