Problem Solving/Programmers
[Level 2] 예상 대진표
kmkunk
2022. 4. 6. 11:23
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;
}
}