标签:des style java color os strong
8 1300 48 2 1 7 0
2504 1000
注意:需要注意的是A+B之后的值有可能超过int的范围,所以要用long long型;还要考虑当和为0是的情况,要输出0(题意为非负,那么就包括0)
#include<iostream>
using namespace std;
int a[100];
int main()
{
long long A,B;
int m;
while(scanf("%d",&m),m)
{
int sum,i=0,j;
scanf("%I64d%I64d",&A,&B);
sum=A+B;
if(sum==0) {printf("0\n");continue;}
while(sum)
{
a[i++]=sum%m;
sum=sum/m;
}
for(j=i-1;j>=0;j--)
printf("%d",a[j]);
printf("\n");
}
return 0;
}
HDU 1877 又一版 A+B,布布扣,bubuko.com
标签:des style java color os strong
原文地址:http://blog.csdn.net/qq_16767427/article/details/38038329