結果
問題 |
No.3127 Multiple of Twin Prime
|
ユーザー |
![]() |
提出日時 | 2025-04-25 21:26:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,142 ms / 2,500 ms |
コード長 | 531 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 165,992 KB |
最終ジャッジ日時 | 2025-04-25 21:26:33 |
合計ジャッジ時間 | 15,502 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
v=[0]*(10**7+10**6) for x in range(2,10**7+10**6): if v[x]==1: continue for y in range(2,10**7): if x*y>=10**7+10**6: break v[x*y]=1 p=[] for x in range(2,10**7+10**6-1): if v[x]==0 and v[x+2]==0: p.append(x) Q=int(input()) from math import isqrt from bisect import bisect_right for _ in range(Q): N=int(input()) K=isqrt(N) pos=bisect_right(p,K) result=-1 for e in range(pos-5,pos+5): if e<0: continue x=p[e] if x*(x+2)<=N: result=max(result,x*(x+2)) print(result)