题目链接
#include<stdio.h>
int main()
{
int m,n;
int b[50],i,j;
while (~scanf("%d%d",&n,&m))
{ j=0;
if(n<0)
{
printf("-");
n= -n;
}
while (n!=0)
{
b[j++]=n%m;
n= n/m;
}
for(i=j-1;i>=0;i--)
{
if(b[i]>=10)
printf("%c",b[i]-10+'A');
else
printf("%d",b[i]);
}
printf("
");
}
return 0;
}