[BOJ / Python] 1193 분수찾기

도니·2023년 4월 8일

BOJ / Python

목록 보기
52/105
post-thumbnail

문제

백준 1193 분수찾기

코드

#BOJ 1193 분수찾기

x = int(input())

tmp = 1
count = 1
while x > tmp:
    count += 1
    tmp += count

if count % 2 == 0:
    numerator = x - (tmp - count)
    denominator = (count + 1) - numerator
else:
    denominator = x - (tmp - count)
    numerator = (count + 1) - denominator

print(str(numerator) + "/" + str(denominator))
profile
Where there's a will, there's a way

0개의 댓글