結果
問題 |
No.2420 Simple Problem
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:20:37 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 83,020 KB |
実行使用メモリ | 97,024 KB |
最終ジャッジ日時 | 2025-03-20 20:21:50 |
合計ジャッジ時間 | 5,850 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 TLE * 2 -- * 29 |
ソースコード
import math from decimal import Decimal, getcontext, ROUND_CEILING getcontext().prec = 20 n = int(input()) for _ in range(n): a, b = map(int, input().split()) # Check if a is a perfect square a_root = math.isqrt(a) is_a_square = a_root * a_root == a # Check if b is a perfect square b_root = math.isqrt(b) is_b_square = b_root * b_root == b if is_a_square and is_b_square: print(a_root + b_root + 1) else: sum_sqrt = Decimal(a).sqrt() + Decimal(b).sqrt() x = sum_sqrt.to_integral_value(rounding=ROUND_CEILING) print(int(x))