結果
問題 |
No.3127 Multiple of Twin Prime
|
ユーザー |
|
提出日時 | 2025-05-10 17:44:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,679 ms / 2,500 ms |
コード長 | 547 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 82,884 KB |
実行使用メモリ | 158,708 KB |
最終ジャッジ日時 | 2025-05-10 17:44:41 |
合計ジャッジ時間 | 23,819 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
from bisect import bisect_right P = list(range(10**7+1)) for i in range(2,10**7+1): if i*i>10**7:break for j in range(i*i,10**7+1,i): P[j] = P[i] Q = [] for i in range(2,10**7+1): if P[i]==i and i+2<10**7 and P[i+2]==i+2: Q.append(i) T = int(input()) for _ in range(T): N = int(input()) ind = bisect_right(Q,N**0.5) if ind-1>=0 and Q[ind-1]*(Q[ind-1]+2)<=N: print(Q[ind-1]*(Q[ind-1]+2)) elif ind-2>=0 and Q[ind-2]*(Q[ind-2]+2)<=N: print(Q[ind-2]*(Q[ind-2]+2)) else: print(-1)