#include <stdio.h>
int num[100];
int poww(int a,int b) {
    int t=1;
    for(int i=0; i<b; i++) {
        t*=a;
    }
    return t;
}
int len=0;
//10진수 a를 b진수로 변환
void change(int a,int b) {
    while(a>0) {
        num[len++]=a%b;
        a=a/b;
    }
}
int main() {
    int old,new,n;
    int total=0;
    scanf("%d %d",&old, &new);
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        int num;
        scanf("%d",&num);
        total+=num*poww(old,n-1-i);
    }
    change(total,new);
    for(int i=len-1; i>=0; i--) {
        printf("%d ",num[i]);
    }
    return 0;
}
//50/8 = 6   2
//6/8=   0   6

Embed on website

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