Skip to content

Commit cc401c8

Browse files
committed
Lv1_3진법뒤집기
1 parent 8ed6cf8 commit cc401c8

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <string>
2+
#include <cmath>
3+
#include <vector>
4+
#include <algorithm>
5+
using namespace std;
6+
7+
int solution(int n) {
8+
int answer = 0;
9+
vector<int> three;
10+
11+
while (n){
12+
three.push_back(n % 3);
13+
n /= 3;
14+
}
15+
reverse(three.begin(), three.end());
16+
17+
for (int i = 0; i < three.size(); ++i)
18+
answer += pow(3, i) * three[i];
19+
20+
return answer;
21+
}

Programmers/Programmers.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<ClCompile Include="Lv1\Lv1_2016년.cpp">
2323
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
2424
</ClCompile>
25+
<ClCompile Include="Lv1\Lv1_3진법뒤집기.cpp">
26+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
27+
</ClCompile>
2528
<ClCompile Include="Lv1\Lv1_K번째수.cpp">
2629
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
2730
</ClCompile>

Programmers/Programmers.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,8 @@
504504
<ClCompile Include="Lv1\Lv1_약수의개수와덧셈.cpp">
505505
<Filter>소스 파일</Filter>
506506
</ClCompile>
507+
<ClCompile Include="Lv1\Lv1_3진법뒤집기.cpp">
508+
<Filter>소스 파일</Filter>
509+
</ClCompile>
507510
</ItemGroup>
508511
</Project>

0 commit comments

Comments
 (0)