結果

問題 No.2420 Simple Problem
ユーザー NakLon131NakLon131
提出日時 2023-08-13 16:01:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 944 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 76,296 KB
最終ジャッジ日時 2023-11-01 00:20:13
合計ジャッジ時間 28,969 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,560 KB
testcase_01 AC 433 ms
76,172 KB
testcase_02 AC 71 ms
70,524 KB
testcase_03 AC 211 ms
76,144 KB
testcase_04 AC 742 ms
76,208 KB
testcase_05 AC 503 ms
76,144 KB
testcase_06 AC 919 ms
76,288 KB
testcase_07 AC 936 ms
76,260 KB
testcase_08 AC 919 ms
76,268 KB
testcase_09 AC 929 ms
76,268 KB
testcase_10 AC 912 ms
76,272 KB
testcase_11 AC 924 ms
76,272 KB
testcase_12 AC 932 ms
76,268 KB
testcase_13 AC 932 ms
76,284 KB
testcase_14 AC 928 ms
76,264 KB
testcase_15 AC 927 ms
76,268 KB
testcase_16 AC 913 ms
76,264 KB
testcase_17 AC 932 ms
76,264 KB
testcase_18 AC 918 ms
76,272 KB
testcase_19 AC 944 ms
76,292 KB
testcase_20 AC 917 ms
76,292 KB
testcase_21 AC 921 ms
76,284 KB
testcase_22 AC 918 ms
76,256 KB
testcase_23 AC 921 ms
76,264 KB
testcase_24 AC 924 ms
76,296 KB
testcase_25 AC 915 ms
76,264 KB
testcase_26 AC 43 ms
59,400 KB
testcase_27 AC 740 ms
76,192 KB
testcase_28 AC 745 ms
76,196 KB
testcase_29 AC 740 ms
76,204 KB
testcase_30 AC 740 ms
76,192 KB
testcase_31 AC 739 ms
76,184 KB
testcase_32 AC 38 ms
53,560 KB
testcase_33 AC 422 ms
76,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

def solve():
	a, b = map(int, input().split())
	# sqrt(a) + sqrt(b) < x
	# 2 * sqrt(ab) < (x^2-a-b)
	# 4ab < (x^2 - a - b) ^ 2

	# 二分探索
	l = 0
	r = 10**5				# sqrt(10^9) = 3.2*10^4が2つなので、10**5程度あればよい
	for i in range(100):
		m = (l + r) // 2

		# valが負、または、val**2 >= 4abなら、値mが小さい
		val = m**2-a-b
		if val < 0 or 4*a*b >= val**2: l = m
		else: r = m
	print(r)

for i in range(n):
	solve()
0