又一版 A+B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12246 Accepted Submission(s): 4629
当m为0时输入结束。
8 1300 48 2 1 7 0
2504 1000
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<stack>
#include<cstdio>
#include<iostream>
using namespace std;
stack<int> p;
int m;
void hanshu(int sum)
{
if(sum==0)
printf("0");
else
{
while(sum>0)
{
p.push(sum%m);
sum=sum/m;
}
}
}
int main()
{
int i,j,a,b;
int sum;
while(scanf("%d",&m)!=EOF)
{
if(m<=0)
break;
scanf("%d%d",&a,&b);
sum=a+b;
hanshu(sum);
while(!p.empty())
{
//printf("%d",p.top());
cout<<p.top();
p.pop();
}
printf("\n");
}
return 0;
}
234



被折叠的 条评论
为什么被折叠?



