class Solution {
public int solution(int n, int a, int b) {
int answer = 1;
int x = Math.min(a,b);
int y = Math.max(a,b);
for(int i=1; i<=20; i++) {
if(y%2==0 && y-x==1) { break; }
x = (x+1)/2;
y = (y+1)/2;
answer++;
}
return answer;
}
}
'Problem Solving > Programmers' 카테고리의 다른 글
[Level 2] 위장 (0) | 2022.04.06 |
---|---|
[Level 2] 괄호 회전하기 (0) | 2022.04.06 |
[Level 2] 조이스틱 (0) | 2022.03.31 |
[Level 2] 소수 찾기 (0) | 2022.03.31 |
[Level 2] 가장 큰 수 (0) | 2022.03.31 |