-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1120.cpp
More file actions
35 lines (33 loc) · 774 Bytes
/
P1120.cpp
File metadata and controls
35 lines (33 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
#define int long long
using namespace std;
string s1,s2;
int a[1000],b[1000];
signed main(){
int n;
cin>>n;
while(n--){
cin>>s1>>s2;
memset(a,0,sizeof a);
memset(b,0,sizeof b);
for(int i=0;i<s1.size();i++)
a[s1.size()-i-1]=s1[i]-'0';
for(int i=0;i<s2.size();i++)
b[s2.size()-1-i]=s2[i]-'0';
int len = max(s1.size(),s2.size());
for(int i=0;i<len;i++){
a[i]=a[i]+b[i];
a[i+1] += a[i]/10;
a[i]%=10;
}
while(a[len]){
a[len+1]+=a[len]/10;
a[len]%=10;
len++;
}
for(int i=len-1;i>=0;i--)
cout<<a[i];
cout<<endl;
}
return 0;
}