백준 2745 c++
#include <iostream>
#include <cstring>
#include <cmath> //수식 함수 헤더
using namespace std;
int main(void)
{
char N[32] = {};
int editted_N[32] = {};
int B, i, dec = 0, len;
cin >> N >> B;
if (B >= 2 && B <= 36)
{
len = (int)strlen(N);
for (i = 0; i < len; i++)
{
if ((int)N[i] >= 65 && (int)N[i] <= 90)
{
editted_N[i] = (int)N[i] - 55;
}
else if ((int)N[i] >= 48 && (int)N[i] <= 57)
{
editted_N[i] = (int)N[i] - 48;
}
else
{
;
}
dec = dec + editted_N[i] * pow(B, len - i - 1);
}
cout << dec << endl;
}
else
{
;
}
return 0;
}