結果
問題 |
No.691 E869120 and Constructing Array 5
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:16:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 757 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 82,336 KB |
実行使用メモリ | 85,184 KB |
最終ジャッジ日時 | 2025-06-12 18:17:20 |
合計ジャッジ時間 | 23,109 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 27 |
ソースコード
from decimal import Decimal, getcontext, ROUND_HALF_UP def main(): import sys input = sys.stdin.read().split() Q = int(input[0]) queries = input[1:Q+1] getcontext().prec = 30 # High precision to handle up to 15 decimal digits for p_str in queries: p = Decimal(p_str) # Step 1: Check if p is the square root of an integer e_candidate = (p ** 2).quantize(Decimal('1.'), rounding=ROUND_HALF_UP) sqrt_e = e_candidate.sqrt() error = abs(sqrt_e - p) if error <= Decimal('1e-10'): print(f"1 {int(e_candidate)}") else: # Use three terms as in the fourth sample print("3 10000000 15000000 20000000") if __name__ == "__main__": main()