https://www.acmicpc.net/problem/1057
1057번: 토너먼트
김지민은 N명이 참가하는 스타 토너먼트에 진출했다. 토너먼트는 다음과 같이 진행된다. 일단 N명의 참가자는 번호가 1번부터 N번까지 배정받는다. 그러고 난 후에 서로 인접한 번호끼리 스타를
www.acmicpc.net
https://github.com/stellaluminary/Baekjoon
GitHub - stellaluminary/Baekjoon
Contribute to stellaluminary/Baekjoon development by creating an account on GitHub.
github.com
n, j, h = map(int, input().split())
round = 1
while 1:
if abs(j-h) == 1 and j//2 != h//2:
print(round)
break
if j % 2 == 1:
j = (j+1)//2
else:
j //= 2
if h % 2 == 1:
h = (h + 1) // 2
else:
h //= 2
round += 1
n,start,end=map(int, input().split())
cnt=0
while start!=end:
start -= start//2
end -= end//2
cnt+=1
print(cnt)