본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#49 백준 파이썬 [1011] Fly me to the Alpha Centauri

https://www.acmicpc.net/problem/1011





#Solutin


case_num = int(input())
ans = []
for i in range(case_num):
a, b = map(int, input().split())
num = b-a
k = 1
p = 1
while num > 0:
num -= k
k += 1
if num >= p:
num -= p
p += 1

ans.append(k+p-2)

for i in ans:
print(i)