BOJ - 1669 - 멍멍이 쓰다듬기

Updated:

import math
def fact(n):
    a = 1
    for i in range(1, n+1):
        a = a * i
    return a

def solution():
    X, Y = map(int, input().split(' '))

    distance = Y - X
    i = 1
    while i * i < distance:
        i = i + 1

    if distance < (i * i) - i + 1:
        print(2 * i - 2)
    else:
        print(2 * i - 1)

solution()

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

Categories:

Updated:

Leave a comment