알고리즘 문제 풀기/BOJ
BOJ 1011 - Fly me to the Alpha Centauri
bug_maker
2019. 12. 23. 15:01
https://www.acmicpc.net/problem/1011
BOJ 1011 - Fly me to the Alpha Centauri
작성언어: Python3
xxxxxxxxxx
import math
t = int(input())
for i in range(t):
start, end = map(int, input().split())
dist = end - start
k = 1
while(k*k <= dist):
k += 1
if(k*k != dist):
k -= 1
dist = math.ceil((dist - k*k) / k)
print(int(k * 2 - 1 + dist))
pc 환경에서 코드를 보는 것을 권장합니다.