結果
| 問題 |
No.691 E869120 and Constructing Array 5
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:17:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 541 ms |
| コンパイル使用メモリ | 82,520 KB |
| 実行使用メモリ | 64,532 KB |
| 最終ジャッジ日時 | 2025-06-12 18:18:06 |
| 合計ジャッジ時間 | 6,169 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 27 |
ソースコード
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.
gew1fw