結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-28 07:34:07 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 5,000 ms |
| コード長 | 578 bytes |
| コンパイル時間 | 120 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 14,080 KB |
| 最終ジャッジ日時 | 2024-10-05 17:32:38 |
| 合計ジャッジ時間 | 4,386 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
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)