// LV2. 124 나라의 숫자
public static String solution_124Country(int n) {
StringBuffer sb = new StringBuffer();
while(n > 0){
int su = n%3==0?3:n%3;
sb.append((int)Math.pow(2,su-1));
n /= 3;
if(su==3) n -= 1;
}
return sb.reverse().toString();
}
'Algorithm > Programmers' 카테고리의 다른 글
[Programmers] LV2. n개의 최소공배수 (1) | 2023.03.15 |
---|---|
[Programmers] LV2. 거리두기 확인하기 (0) | 2023.03.15 |
[Programmers] LV2. 멀쩡한 사각형 (0) | 2023.03.15 |
[Programmers] LV2. 오픈채팅방 (0) | 2023.03.15 |
[Programmers] LV2. 더 맵게 (0) | 2023.03.13 |