Submission #2325009

Source Code Expand

Copy
# editorial解法
from math import sqrt
Q = int(input())
for i in range(Q):
	A,B = map(int,input().split(" "))
	if A == B or A + 1 == B:
		print(2*A-2)
		continue

	mul = A * B
	C = int(sqrt(mul))
	if C * C == mul:
		C -= 1
	if (C + 1) * C < mul:
		print((2*C) - 1) #(A-1) + (2*C - A)
	else:
		print((2*C) - 2) #(A-1) + (2*C - A - 1)

Submission Info

Submission Time
Task D - Worst Case
User banboooo044
Language Python3 (3.4.3)
Score 700
Code Size 353 Byte
Status
Exec Time 18 ms
Memory 3060 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt
All 700 / 700 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, s1.txt
Case Name Status Exec Time Memory
01.txt 18 ms 3060 KB
02.txt 18 ms 3060 KB
03.txt 18 ms 3060 KB
04.txt 18 ms 3060 KB
05.txt 18 ms 3060 KB
06.txt 18 ms 3060 KB
07.txt 18 ms 3060 KB
08.txt 18 ms 3060 KB
09.txt 18 ms 3060 KB
10.txt 18 ms 3060 KB
11.txt 17 ms 3060 KB
s1.txt 17 ms 3060 KB