結果

問題 No.691 E869120 and Constructing Array 5
ユーザー gew1fw
提出日時 2025-06-12 12:54:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 64,548 KB
最終ジャッジ日時 2025-06-12 12:58:40
合計ジャッジ時間 5,811 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

Q = int(input())
sum_coeff = math.sqrt(2) + math.sqrt(3) + 2.0  # Precompute the sum of sqrt(2), sqrt(3), and 2

for _ in range(Q):
    P_str = input().strip()
    P = float(P_str)
    
    # Try single term
    e_single = round(P ** 2)
    if abs(math.sqrt(e_single) - P) <= 1e-10:
        print(f"1 {e_single}")
        continue
    
    # Try three terms
    m_exact = (P / sum_coeff) ** 2
    m_rounded = round(m_exact)
    e1 = 2 * m_rounded
    e2 = 3 * m_rounded
    e3 = 4 * m_rounded
    sum_three = math.sqrt(e1) + math.sqrt(e2) + math.sqrt(e3)
    if abs(sum_three - P) <= 1e-10:
        print(f"3 {e1} {e2} {e3}")
        continue
    
    # If neither works, this part would need to be extended, but for the problem's constraints, it's sufficient.
    # Additional strategies can be added here if necessary.
0