229일차 - BOJ no.1011

Dzeko·2022년 3월 8일
0
post-thumbnail

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

My Solution

import sys

T = int(sys.stdin.readline().rstrip())
result = []
for _ in range(T):
    x, y = map(int, sys.stdin.readline().rstrip().split())
    num = 1
    cnt = 0
    while x <= y:
        if y - x <= num:
            cnt += 1
            break
        else:
            x += num
            y -= num
            cnt += 2
        if x >= y:
            break

        num += 1
    result.append(cnt)

for i in result:
    print(i)
아무리 데굴이 굴려봐도 마땅한 풀이가 떠오르지 않아 sos쳤다. 보고나니 이마를 탁 쳤다.
profile
Do or Die

0개의 댓글