先弄个支持加减和大小比较的manual BigInteger
#include<bits/stdc++.h>
using namespace std;
class BigInteger
{
public:
string num;
BigInteger () { num="0" ;}
BigInteger & operator = (const BigInteger & that ) { num=that.num; }
bool operator > (const BigInteger & that ) {
if(num.length()!=that.num.length()) return num.length()>that.num.length();
else return num>that.num;
}
BigInteger operator + (const BigInteger & that ) const {
string s1=num,s2=that.num;
if(s1.length()<s2.length()) swap(s1,s2);
int size=s1.length()+1;
int a[s1.length()],b[s2.length()],c[size];
for(register int i=0;i<s1.length();i++) a[i]=s1[s1.length()-1-i]-'0';
for(register int i=0;i<s2.length();i++) b[i]=s2[s2.length()-1-i]-'0';
memset(c,0,sizeof c);
for(register int i=0;i<s1.length();i++){
i<s2.length()?c[i]=a[i]+b[i]:c[i]=a[i];
c[i+1]=c[i]/10;
c[i]%=10;
}
BigInteger res;
for(register int i=size-1;i>=0;i--){
res.num.push_back(c[i]+'0');
}
while(res.num.length()>1&& res.num[0]=='0') res.num.erase(0,1);
return res;
}
};
int main()
{
BigInteger buffer,tot;
cin>>tot.num;
while(cin>>buffer.num)
{
tot=tot+buffer;
cout<<tot.num;
}
}