結果

問題 No.3127 Multiple of Twin Prime
ユーザー lif4635
提出日時 2025-01-20 13:21:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 515 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 102,152 KB
最終ジャッジ日時 2025-01-20 14:22:10
合計ジャッジ時間 53,578 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1
other TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt
from functools import cache
import sys
sys.setrecursionlimit(10**7)

lim = 10**7 + 10
prime_flag = [1]*lim
prime_flag[0] = 0
prime_flag[1] = 0
for p in range(2,lim):
    if prime_flag[p]:
        for q in range(2*p,lim,p):
            prime_flag[q] = 0

@cache
def search(x):
    if prime_flag[x]&prime_flag[x+2]: return x*(x+2)
    return search(x-1)

t = int(input())
for i in range(t):
    n = int(input())
    if n <= 14:
        print(-1)
        continue
    print(search(isqrt(n+1)-1))
0