結果

問題 No.6 使いものにならないハッシュ
ユーザー hiro1729hiro1729
提出日時 2023-07-28 07:34:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 578 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-15 16:53:20
合計ジャッジ時間 4,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
13,184 KB
testcase_01 AC 99 ms
13,056 KB
testcase_02 AC 134 ms
14,080 KB
testcase_03 AC 102 ms
13,312 KB
testcase_04 AC 112 ms
13,312 KB
testcase_05 AC 111 ms
13,440 KB
testcase_06 AC 121 ms
13,568 KB
testcase_07 AC 106 ms
13,440 KB
testcase_08 AC 115 ms
13,440 KB
testcase_09 AC 104 ms
13,440 KB
testcase_10 AC 99 ms
13,056 KB
testcase_11 AC 104 ms
13,312 KB
testcase_12 AC 123 ms
13,696 KB
testcase_13 AC 104 ms
13,056 KB
testcase_14 AC 100 ms
13,184 KB
testcase_15 AC 115 ms
13,568 KB
testcase_16 AC 110 ms
13,312 KB
testcase_17 AC 124 ms
13,952 KB
testcase_18 AC 132 ms
13,824 KB
testcase_19 AC 120 ms
13,696 KB
testcase_20 AC 122 ms
13,608 KB
testcase_21 AC 104 ms
13,232 KB
testcase_22 AC 119 ms
13,568 KB
testcase_23 AC 123 ms
13,696 KB
testcase_24 AC 122 ms
13,568 KB
testcase_25 AC 109 ms
13,312 KB
testcase_26 AC 128 ms
13,696 KB
testcase_27 AC 125 ms
13,568 KB
testcase_28 AC 115 ms
13,440 KB
testcase_29 AC 129 ms
13,824 KB
testcase_30 AC 126 ms
13,824 KB
testcase_31 AC 121 ms
13,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 300000
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())
p = []
h = []
for i in range(k, n + 1):
    if isprime[i]:
        p.append(i)
        h.append(i % 9)
max_ = 0
ans = 0
le = len(p)
tf = [False] * 9
r = 0
for l in range(le):
    while r < le and not tf[h[r]]:
        tf[h[r]] = True
        r += 1
    if r - l >= max_:
        max_ = r - l
        ans = p[l]
    tf[h[l]] = False
print(ans)
0