結果

問題 No.3127 Multiple of Twin Prime
ユーザー lif4635
提出日時 2025-01-20 13:20:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 575 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 376,736 KB
最終ジャッジ日時 2025-01-20 14:21:46
合計ジャッジ時間 22,339 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import isqrt
from functools import cache
import sys
sys.setrecursionlimit(10**7)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

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