結果

問題 No.6 使いものにならないハッシュ
ユーザー 👑 colognecologne
提出日時 2022-01-20 15:30:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 718 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 78,100 KB
最終ジャッジ日時 2023-08-15 13:00:19
合計ジャッジ時間 4,399 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,256 KB
testcase_01 AC 66 ms
71,372 KB
testcase_02 AC 90 ms
78,044 KB
testcase_03 AC 73 ms
76,796 KB
testcase_04 AC 75 ms
76,756 KB
testcase_05 AC 73 ms
76,740 KB
testcase_06 AC 77 ms
77,596 KB
testcase_07 AC 75 ms
77,012 KB
testcase_08 AC 75 ms
77,600 KB
testcase_09 AC 78 ms
77,872 KB
testcase_10 AC 63 ms
71,280 KB
testcase_11 AC 73 ms
76,568 KB
testcase_12 AC 76 ms
77,336 KB
testcase_13 AC 78 ms
77,728 KB
testcase_14 AC 78 ms
77,920 KB
testcase_15 AC 76 ms
77,132 KB
testcase_16 AC 77 ms
77,828 KB
testcase_17 AC 80 ms
77,856 KB
testcase_18 AC 78 ms
77,860 KB
testcase_19 AC 77 ms
77,976 KB
testcase_20 AC 78 ms
77,456 KB
testcase_21 AC 72 ms
76,156 KB
testcase_22 AC 79 ms
77,720 KB
testcase_23 AC 75 ms
77,412 KB
testcase_24 AC 74 ms
77,520 KB
testcase_25 AC 74 ms
77,676 KB
testcase_26 AC 82 ms
78,100 KB
testcase_27 AC 78 ms
77,704 KB
testcase_28 AC 76 ms
77,020 KB
testcase_29 AC 78 ms
77,656 KB
testcase_30 AC 80 ms
77,436 KB
testcase_31 AC 80 ms
77,272 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