#include "stdio.h"
#include "stdlib.h"
int main(){
char a[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int s,b,n[100],i,flag;
while(~scanf("%d%d",&s,&b)){
i=0;
flag=0;
if(s<0){
s=abs(s);
flag=1;
}
while(s/b!=0){
n[i]=s%b;
i++;
s=s/b;
}
n[i]=s;
if(flag==0){
for(;i>=0;i--)
printf("%c",a[n[i]]);
printf("\n");
}
else
{
printf("%c",'-');
for(;i>=0;i--)
printf("%c",a[n[i]]);
printf("\n");
}
}
return 0;
}
hdoj-2031
最新推荐文章于 2016-10-26 19:49:00 发布