結果
問題 | No.6 使いものにならないハッシュ |
ユーザー |
👑 |
提出日時 | 2022-06-12 15:47:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 60 ms / 5,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 81,992 KB |
実行使用メモリ | 68,260 KB |
最終ジャッジ日時 | 2024-09-23 04:01:53 |
合計ジャッジ時間 | 3,164 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
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)