Skip to content

Commit

Permalink
[level 2] Title: 124 나라의 숫자, Time: 0.01 ms, Memory: 3.81 MB -BaekjoonHub
Browse files Browse the repository at this point in the history
  • Loading branch information
developeSHG committed Jul 28, 2023
1 parent 5f08c01 commit 1a634ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ using namespace std;

string solution(int n) {
string answer = "", str = "412";
bool three = (n % 3 == 0);
n -= three ? 1 : 0;

while (n)
{
answer = str[n % 3] + answer;
if (n % 3 == 0) --n;
if (n % 3 == 0) --n; // 3인 경우는 4로 표현하기 때문에 -1
n = n / 3;
}

if (three) answer.back() = '4';
return answer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### 성능 요약

메모리: 3.8 MB, 시간: 0.01 ms
메모리: 3.81 MB, 시간: 0.01 ms

### 구분

Expand Down

0 comments on commit 1a634ae

Please sign in to comment.