|
- // luogu-judger-enable-o2
- #include <iostream>
- #include <cmath>
- using namespace std;
- const int LENGTH = 505;
- int a[LENGTH],b[LENGTH];
- int la,lb,lc;
- int c[LENGTH];
- int main()
- {
- string sa,sb;
- cin>> sa >> sb;
- la=sa.size(); lb=sb.size();
- for(int i=1;i<=la;i++) a[i] = sa[la - i]-'0';
- for(int i=1;i<=lb;i++) b[i] = sb[lb - i]-'0';
- lc=max(la , lb);
- for(int i=1;i<=lc;i++) c[i]=a[i]+b[i];
- for(int i=1;i<=lc;i++)
- if(c[i]>=10)
- {
- c[i]-=10;
- c[i+1]++;
- }
- if(c[lc+1]!=0) lc++;
- for(int i=lc;i>=1;--i) cout << c[i];
- return 0;
- }
复制代码 |
|