题目链接
思路
用栈存放,先进后出
测试点3不过可能是没考虑a+b为0的情况
AC代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=1e6;
stack<int> s;
int main()
{
ll a,b,c;
cin>>a>>b>>c;
ll d=a+b;
if(d==0)
{
cout<<0<<endl;
return 0;
}
while(d!=0)
{
s.push(d%c);
d/=c;
}
while(!s.empty())
{
cout<<s.top();
s.pop();
}
cout<<endl;
return 0;
}