백준 1011 - Fly me to the Alpha Centauri (파이썬)

Updated:

Answer

T = int(input())

for _ in range(T):
    x, y = map(int, input().split())
    y = y - x
    x = int(pow(y - 1, 0.5))
    
    if x ** 2 < y <= x ** 2 + x:
        print(x * 2)
    else:
        print(x * 2 + 1)

Categories:

Updated: