結果

問題 No.6 使いものにならないハッシュ
ユーザー 👑 colognecologne
提出日時 2022-01-20 15:30:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 70,600 KB
最終ジャッジ日時 2024-05-03 00:31:28
合計ジャッジ時間 2,739 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,400 KB
testcase_01 AC 35 ms
52,896 KB
testcase_02 AC 54 ms
70,600 KB
testcase_03 AC 45 ms
63,380 KB
testcase_04 AC 46 ms
63,536 KB
testcase_05 AC 43 ms
65,552 KB
testcase_06 AC 50 ms
68,164 KB
testcase_07 AC 48 ms
65,256 KB
testcase_08 AC 46 ms
66,632 KB
testcase_09 AC 49 ms
65,492 KB
testcase_10 AC 32 ms
52,580 KB
testcase_11 AC 42 ms
63,516 KB
testcase_12 AC 51 ms
67,508 KB
testcase_13 AC 52 ms
64,720 KB
testcase_14 AC 52 ms
64,324 KB
testcase_15 AC 49 ms
65,976 KB
testcase_16 AC 49 ms
66,356 KB
testcase_17 AC 54 ms
69,760 KB
testcase_18 AC 50 ms
70,032 KB
testcase_19 AC 51 ms
68,624 KB
testcase_20 AC 53 ms
66,664 KB
testcase_21 AC 45 ms
62,024 KB
testcase_22 AC 55 ms
68,716 KB
testcase_23 AC 53 ms
67,300 KB
testcase_24 AC 51 ms
66,744 KB
testcase_25 AC 51 ms
65,500 KB
testcase_26 AC 55 ms
69,928 KB
testcase_27 AC 51 ms
66,912 KB
testcase_28 AC 49 ms
65,728 KB
testcase_29 AC 52 ms
68,584 KB
testcase_30 AC 49 ms
69,380 KB
testcase_31 AC 48 ms
68,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import itertools

input = sys.stdin.readline

def main():
    K = int(input())
    N = int(input())

    sieve = [True] * (N+1)

    primes = []

    for i in range(2, N+1):
        if sieve[i]:
            if i >= K: primes.append(i)
            for j in range(i*i, N+1, i):
                sieve[j] = False

    maxv = 0

    for i in range(len(primes)-1, -1, -1):
        vis = [False]*9

        for j in range(i, len(primes)):
            if not vis[primes[j]%9]:
                vis[primes[j]%9] = True
                if maxv < j-i+1:
                    maxv = j-i+1
                    ans = primes[i]
            else:
                break

    print(ans)


if __name__ == '__main__':
    main()
0