結果
| 問題 |
No.3127 Multiple of Twin Prime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-26 04:41:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 610 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 230,092 KB |
| 最終ジャッジ日時 | 2025-04-26 04:41:52 |
| 合計ジャッジ時間 | 8,632 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 |
| other | -- * 12 |
ソースコード
from math import isqrt
from bisect import bisect_right
MAX = 10**7
temp = [True] * (MAX + 1)
temp[0:2] = [False, False]
for i in range(2, isqrt(MAX) + 1):
if temp[i]:
for j in range(i*i, MAX+1, i):
temp[j] = False
primes = list(enumerate(temp))
L = [i for i, p in primes if p and list(primes[i+2])[1]]
T = int(input())
for _ in range(T):
N = int(input())
i = bisect_right(L, isqrt(N))
if i >= len(L):
i = len(L)-1
while L[i]*(L[i]+2) > N:
i -= 1
if i < 0:
break
if i==-1:
print(-1)
else:
print(L[i]*(L[i]+2))