結果

問題 No.6 使いものにならないハッシュ
ユーザー HimatsubushinHimatsubushin
提出日時 2019-12-24 14:27:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 12,056 KB
実行使用メモリ 15,816 KB
最終ジャッジ日時 2023-10-21 22:35:21
合計ジャッジ時間 25,482 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
10,084 KB
testcase_01 WA -
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 Hash(number):
    while number >= 10:
        number = int(number / 10) + number % 10

    return number


k = int(input())
n = int(input())
numbers = [False for _ in range(n + 1)]
prime = []
max = 0

if k <= 2:
    prime.append(2)

for i in range(3, n + 1, 2):
    numbers[i] = True

for i in range(3, n, 2):
    j = 2
    while i * j <= n:
        numbers[i * j] = False
        j += 2

for i in range(k + 1 - k % 2, n + 1, 2):
    if numbers[i]:
        prime.append(i)

for i in range(0, len(prime) - 1, 1):
    checker = [False for _ in range(10)]
    count = 1
    checker[Hash(prime[i])] = True

    j = 1
    while j < 11 and i + j < len(prime):
        value = Hash(prime[i + j])

        if not checker[value]:
            checker[value] = True
            count += 1
        else:
            break
        j += 1

    if max <= count:
        max = count
        start = prime[i]

print(start)
0