結果

問題 No.6 使いものにならないハッシュ
ユーザー nebukuro09nebukuro09
提出日時 2016-09-30 09:49:11
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-01 08:10:04
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 9 ms
6,400 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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[r]
            exit()
0