#include <stdio.h>
#include <string.h>
//제곱
int poww(int a,int b) {
    int res=1;
    for(int i=0; i<b; i++) {
        res*=a;
    }
    return res;
}
int main() {
    int b,res=0;
    char num[10000];
    scanf("%s %d",num, &b);
    int len=strlen(num);
    int tmp=len-1;
    for(int i=0; i<len; i++) {
        if(num[i]>='0' && num[i]<='9') {
            res+=(num[i]-'0')*poww(b,tmp);
        } else if(num[i]>='A' && num[i]<='Z') {
            res+=(num[i]-55)*poww(b,tmp);
        }
        tmp--;
    }
    printf("%d",res);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: