본문 바로가기
알고리즘/백준

백준-1011번(Fly me to the Alpha Centauri )-python3

by nyeongha 2023. 11. 23.
import math
for x in range(int(input())):
    a,b=map(int,input().split())
    k=round(math.sqrt(b-a))
    if (k**2)-k+1<=(b-a)<=k**2:
        print(2*k-1)
    elif (k**2)+1<=(b-a)<=k**2+k:
        print(2*k)

'알고리즘 > 백준' 카테고리의 다른 글

백준-1038번(감소하는 수)-python3  (0) 2023.11.23
백준-1012번(유기농 배추)-python3  (0) 2023.11.23
백준-1008(A/B)-python  (0) 2023.11.23
백준-1003번(피보나치수열)-python  (0) 2023.11.23
백준-1002번(터렛)-python3  (0) 2023.11.23