티스토리 뷰
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
int n, b;
scanf("%d %d", &n, &b);
int rest;
string result = "";
while (n > 0)
{
rest = n % b;
n = n / b;
if (rest < 10)
{
result = to_string(rest) + result;
}
else
{
result = (char)('A' + rest - 10) + result;
}
}
cout << result << endl;
}
'알고리즘 > 알고리즘' 카테고리의 다른 글
[기본 알고리즘] 유니온 파인드 (union-find) (0) | 2021.10.10 |
---|---|
[최단거리 알고리즘] 다익스트라(Dijkstra), 플로이드와샬(FloydWarshall) (0) | 2021.10.07 |
[기본 알고리즘] 약수 구하기 (0) | 2021.10.04 |
[기본 알고리즘] 최대공약수(GCD), 최소공배수(LCM) 구하기 (0) | 2021.10.04 |
[기본 알고리즘] 알고리즘 - 문제풀이 매핑 (0) | 2021.10.04 |