간단한 수학 문제였다.
핵심은 지민이와 한수가 만나는 위치를 찾는 것이다.
지민이와 한수가 각각 다음 라운드에서 가지게 되는 순번은 현재 각자가 가진 번호가 a,b라고 할 때, 다음 라운드에서는 (a+1)/2, (b+1)/2가 된다.
(a+1)/2, (b+1)/2 이 둘이 같다면 현재 라운드에서 두 사람은 대결을 한다는 의미이기 때문에 반복문을 멈춰주면 된다.
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
int t;
int n;
int m;
int a, b;
int arr[1000001];
static int cnt = 0;
int getRound() {
int round = 1;
while (n>1) {
if ((a + 1) / 2 == (b + 1) / 2)
break;
a = (a + 1) / 2;
b = (b + 1) / 2;
round++;
n = n / 2;
}
if (n == 0)
return -1;
return round;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> a >> b;
cout << getRound() << '\n';
}