結果

問題 No.6 使いものにならないハッシュ
ユーザー 👑 rin204rin204
提出日時 2022-06-12 15:47:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 68,236 KB
最終ジャッジ日時 2023-10-24 11:43:33
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
61,304 KB
testcase_01 AC 44 ms
61,304 KB
testcase_02 AC 53 ms
66,448 KB
testcase_03 AC 54 ms
65,912 KB
testcase_04 AC 55 ms
65,936 KB
testcase_05 AC 54 ms
65,912 KB
testcase_06 AC 55 ms
65,932 KB
testcase_07 AC 54 ms
63,836 KB
testcase_08 AC 53 ms
65,904 KB
testcase_09 AC 52 ms
63,856 KB
testcase_10 AC 43 ms
61,304 KB
testcase_11 AC 54 ms
65,912 KB
testcase_12 AC 56 ms
67,964 KB
testcase_13 AC 49 ms
63,824 KB
testcase_14 AC 53 ms
65,904 KB
testcase_15 AC 53 ms
65,904 KB
testcase_16 AC 54 ms
65,908 KB
testcase_17 AC 52 ms
65,904 KB
testcase_18 AC 57 ms
68,236 KB
testcase_19 AC 56 ms
67,980 KB
testcase_20 AC 61 ms
67,964 KB
testcase_21 AC 52 ms
63,836 KB
testcase_22 AC 57 ms
65,904 KB
testcase_23 AC 53 ms
65,904 KB
testcase_24 AC 54 ms
65,904 KB
testcase_25 AC 57 ms
65,908 KB
testcase_26 AC 55 ms
65,912 KB
testcase_27 AC 53 ms
65,904 KB
testcase_28 AC 53 ms
65,904 KB
testcase_29 AC 53 ms
65,904 KB
testcase_30 AC 57 ms
67,980 KB
testcase_31 AC 54 ms
65,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 200200
isprime = [True] * N
isprime[0] = isprime[1] = False
for i in range(2, int(N ** 0.5 + 1)):
    if not isprime[i]:
        continue
    for j in range(i * i, N, i):
        isprime[j] = False

k = int(input())
n = int(input())
primes = []
hashes = []
for i in range(k, n + 1):
    if isprime[i]:
        primes.append(i)
        hashes.append(i % 9)
max_ = 0
ans = 0
le = len(primes)
tf = [False] * 9
r = 0
for l in range(le):
    while r < le and not tf[hashes[r]]:
        tf[hashes[r]] = True
        r += 1
    if r - l >= max_:
        max_ = r - l
        ans = primes[l]
    tf[hashes[l]] = False
print(ans)
0