문제

#include <iostream>
#include <cmath> // log
using namespace std;

int solution(int n, int a, int b) { // binary search
	int answer = int(log(n) / log(2)); // 최대 라운드 수
	int lo, hi, mid;

	lo = 1, hi = n;

	while (answer > 1) {
		mid = (lo + hi) / 2;
		if (a <= mid && b <= mid) {
			hi = mid;
			answer--;
		}
		else if (a > mid && b > mid) {
			lo = mid + 1;
			answer--;
		}
		else break;
	}
	return answer;
}

int solution2(int n, int a, int b) {
	int answer = 0;
	a--;
	b--;
	while (a != b) {
		a /= 2;
		b /= 2;
		answer++;
	}
	return answer;
}