結果

問題 No.6 使いものにならないハッシュ
ユーザー nebukuro09nebukuro09
提出日時 2016-09-30 09:52:15
言語 Python2
(2.7.18)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 622 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 6,604 KB
実行使用メモリ 8,260 KB
最終ジャッジ日時 2023-10-14 23:03:00
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,000 KB
testcase_01 AC 11 ms
6,040 KB
testcase_02 AC 178 ms
8,260 KB
testcase_03 AC 38 ms
6,288 KB
testcase_04 AC 49 ms
6,668 KB
testcase_05 AC 58 ms
6,616 KB
testcase_06 AC 99 ms
7,120 KB
testcase_07 AC 68 ms
7,052 KB
testcase_08 AC 92 ms
7,128 KB
testcase_09 AC 68 ms
7,336 KB
testcase_10 AC 11 ms
6,192 KB
testcase_11 AC 40 ms
6,192 KB
testcase_12 AC 119 ms
7,312 KB
testcase_13 AC 57 ms
7,448 KB
testcase_14 AC 64 ms
7,448 KB
testcase_15 AC 98 ms
7,200 KB
testcase_16 AC 81 ms
7,312 KB
testcase_17 AC 130 ms
8,020 KB
testcase_18 AC 165 ms
7,976 KB
testcase_19 AC 128 ms
7,600 KB
testcase_20 AC 114 ms
7,404 KB
testcase_21 AC 27 ms
6,196 KB
testcase_22 AC 121 ms
7,716 KB
testcase_23 AC 114 ms
7,372 KB
testcase_24 AC 117 ms
7,368 KB
testcase_25 AC 75 ms
7,056 KB
testcase_26 AC 138 ms
7,580 KB
testcase_27 AC 109 ms
7,716 KB
testcase_28 AC 75 ms
6,860 KB
testcase_29 AC 147 ms
7,596 KB
testcase_30 AC 132 ms
7,600 KB
testcase_31 AC 119 ms
7,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_table(k, n):
    list = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
            while j <= n:
                list[j] = False
                j += i
        i += 1

    table = [i for i in xrange(n + 1) if list[i] and i >= 2 and i >= k]
    return table

def _hash(n):
    while n >= 10:
        n = sum(int(s) for s in str(n))
    return n

K = input()
N = input()

p = prime_table(K, N)
h = map(_hash, p)

for r in xrange(9, 0, -1):
    for i in xrange(len(p)-r, -1, -1):
        if len(set(h[i:i+r])) == r:
            print p[i]
            exit()
0