結果
問題 |
No.3127 Multiple of Twin Prime
|
ユーザー |
![]() |
提出日時 | 2025-07-13 19:20:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 940 ms / 2,500 ms |
コード長 | 578 bytes |
コンパイル時間 | 456 ms |
コンパイル使用メモリ | 82,672 KB |
実行使用メモリ | 205,264 KB |
最終ジャッジ日時 | 2025-07-13 19:20:31 |
合計ジャッジ時間 | 14,383 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
from bisect import bisect def PrimeList(N): P = [1] * (N + 1) P[0] = P[1] = 0 for i in range(2, N + 1): if P[i]: for j in range(i + i, N + 1, i): P[j] = 0 PL = [] for i in range(N + 1): if P[i] == 1: PL.append(i) return PL A = [-1] PL = PrimeList(10**7) PLN = len(PL) for i in range(1, PLN): if PL[i] - PL[i-1] == 2: mp = PL[i] * PL[i-1] if mp > 10 ** 14: break A.append(mp) for _ in range(int(input())): N = int(input()) print(A[bisect(A,N) - 1])