2 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=260; int a[N],b[N],c[N]; string s1,s2; int main() { cin>>s1>>s2; int lena=s1.size(); int lenb=s2.size(); int lenc=max(lena,lenb)+1; for(int i=0,j=s1.size()-1;j>=0;i++,j--) { a[i]=s1[j]-'0'; } for(int i=0,j=s2.size()-1;j>=0;i++,j--) { b[i]=s2[j]-'0'; } int t=0; for(int i=0;i<=lenc;i++) { t=t+a[i]+b[i]; c[i]=t%10; t/=10; } while(lenc>0&&c[lenc]==0) lenc--; for(int i=lenc;i>=0;i--) { cout<<c[i]; } return 0; }
Information
- ID
- 143
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 84
- Accepted
- 28
- Uploaded By