백준 1011 풀이
Updated:
1011
Fly me to the Alpha Centauri
문제의 최초 접근 : 규칙 찾기
Rule
! 문제를 다양한 각도에서 해석하고, 시도해봐야함을 배움
source code
for i in range (eval(input())):
a , b = map(int, input.split())
distance = b - a
handler = 1
while True:
if handler ** 2 < handler <= (handler + 1 ** 2):
break
handler += 1
if handler ** 2 == distance:
print(handler - 1)
elif handler ** 2 < handler <= handler ** 2 + handler:
print(handler * 2)
else:
print((handler * 2) + 1)
Leave a comment