注意最大和最小值就OK了。
SampleInput:
8 1300 48
2 1 7
2 2147483647 2147483647
2 0 0
0
SampleOutput:
2504
1000
11111111111111111111111111111110
0
#include <iostream>
#define MAXN 35
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
long long m,a,b;
int res[MAXN];
while(cin>>m, m!=0)
{
cin >> a >> b;
long long sum = a+b;
int loc = 0;
if(sum != 0){
while(sum != 0)
{
res[loc++] = sum%m;
sum /= m;
}
for(int i=loc-1; i>=0; i--)
cout << res[i];
}
else cout << sum;
cout << endl;
}
return 0;
}