結果

問題 No.6 使いものにならないハッシュ
ユーザー HimatsubushinHimatsubushin
提出日時 2019-12-24 14:41:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 909 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 10,476 KB
最終ジャッジ日時 2023-10-14 23:21:16
合計ジャッジ時間 9,091 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,264 KB
testcase_01 AC 15 ms
8,304 KB
testcase_02 AC 416 ms
10,476 KB
testcase_03 AC 76 ms
8,516 KB
testcase_04 AC 130 ms
8,832 KB
testcase_05 AC 122 ms
8,908 KB
testcase_06 AC 255 ms
9,648 KB
testcase_07 AC 215 ms
9,540 KB
testcase_08 AC 255 ms
9,364 KB
testcase_09 AC 293 ms
9,644 KB
testcase_10 RE -
testcase_11 AC 76 ms
8,444 KB
testcase_12 AC 276 ms
9,800 KB
testcase_13 AC 265 ms
9,684 KB
testcase_14 AC 278 ms
9,684 KB
testcase_15 AC 235 ms
9,452 KB
testcase_16 AC 284 ms
9,696 KB
testcase_17 AC 373 ms
9,992 KB
testcase_18 AC 396 ms
10,440 KB
testcase_19 AC 344 ms
10,056 KB
testcase_20 AC 293 ms
9,792 KB
testcase_21 AC 50 ms
8,576 KB
testcase_22 AC 340 ms
9,948 KB
testcase_23 AC 270 ms
9,776 KB
testcase_24 AC 298 ms
9,688 KB
testcase_25 AC 225 ms
9,484 KB
testcase_26 AC 362 ms
10,056 KB
testcase_27 AC 307 ms
9,808 KB
testcase_28 AC 178 ms
9,120 KB
testcase_29 AC 366 ms
10,056 KB
testcase_30 AC 322 ms
9,928 KB
testcase_31 AC 310 ms
9,764 KB
権限があれば一括ダウンロードができます

ソースコード

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 += 1

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