๋ฐ์ํ
https://programmers.co.kr/learn/courses/30/lessons/12985
์ฝ๋
class Solution
{
public int solution(int n, int a, int b)
{
int answer = 0;
while(a != b){
answer ++;
a = (a+1)/2;
b = (b+1)/2;
}
return answer;
}
}
ํ์ด
๋ฐฑ์ค 1057๋ฒ ํ ๋๋จผํธ ๋ฌธ์ ์ ๋์ผํ๋ค. ๋ฐ๋ผ์ ํ์ด๋ ์๋ ์ฌ์ดํธ ์ฐธ๊ณ !
ํ์ด <
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ๋ก๊ทธ๋๋จธ์ค[Java] - (Level3)๋ฐฉ๋ฌธ ๊ธธ์ด (0) | 2020.03.17 |
---|---|
[Codeforces] 1005A: Tanya and Stairways (0) | 2020.03.17 |
ํ๋ก๊ทธ๋๋จธ์ค[Java] - (Level2)์ฃผ์๊ฐ๊ฒฉ (0) | 2020.03.16 |
ํ๋ก๊ทธ๋๋จธ์ค[Java] - (Level2)๊ฐ์ฅ ํฐ ์ ์ฌ๊ฐํ์ฐพ๊ธฐ(DP) (0) | 2020.03.16 |
ํ๋ก๊ทธ๋๋จธ์ค[Java] - (Level2)ํผ๋ณด๋์น ์(์ฌ๊ท , ๋น์ฌ๊ทDP) (0) | 2020.03.16 |
๋๊ธ