728x90
์ฌ๊ทํจ์๋ก ํ์๋ค๊ฐ ์ฝ๋ ๋ญ๋น๊ฐ ๋ง์์ ธ์ ๋ฌดํ๋ฃจํ ์์์ ํด๊ฒฐํ๋ค.
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string solution(int n) {
string answer = "";
int top = n;
int bottom = 0;
while(true) {
bottom = top % 3;
top = top / 3;
switch(bottom) {
case 0:
answer = '4' + answer;
top -= 1;
break;
case 1:
answer = '1' + answer;
break;
case 2:
answer = '2' + answer;
break;
}
if(top == 0)
break;
}
return answer;
}