-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUGCAL.cpp
More file actions
61 lines (53 loc) · 1.07 KB
/
BUGCAL.cpp
File metadata and controls
61 lines (53 loc) · 1.07 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
unsigned long int a,b;
cin>>a>>b;
if(b>a)
{
swap(a,b);
}
vector<unsigned long int> v1;
vector<unsigned long int> v2;
while(a>0)
{
v1.push_back(a%10);
a=a/10;
}
while(b>0)
{
v2.push_back(b%10);
b=b/10;
}
while(v1.size()<v2.size())
{
v1.push_back(0);
}
while(v2.size()<v1.size())
{
v2.push_back(0);
}
int x=v1.size();
vector<unsigned long int> p;
for(int i=0;i<x;i++)
{
int a=v1[i]+v2[i];
a=a%10;
p.push_back(a);
}
long int ans=0;
reverse(p.begin(),p.end());
vector<unsigned long int>::iterator it;
for(it=p.begin();it!=p.end();it++)
{
ans=ans*10+(*it)%10;
}
cout<<ans<<endl;
}
return 0;
}