题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1877
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main()
{
int a1,b,m,n;
while(~scanf("%d",&m),m)
{
scanf("%d%d",&a1,&b);
n=a1+b;
if(n==0)
cout<<0;
else if(n>0)
{
int i=0;
while(n>0)
{
i++;
a[i]=n%m;
n=n/m;
}
for(int j=i;j>=1;j--)
printf("%d",a[j]);
}
else
{
int i=0;
cout<<"-";
n=-n;
while(n>0)
{
i++;
a[i]=n%m;
n=n/m;
}
for(int j=i;j>=1;j--)
printf("%d",a[j]);
}
cout<<endl;
}
return 0;
}