Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- , \ / ,
- / \ )\__/( / \
- / \ (_\ /_) / \
- ____/_____\__\@ @/___/_____\____
- | |\../| |
- | \VV/ |
- | ------___------- |
- |__________Chuta Dragon___________|
- | /\ / \\ \ /\ |
- | / V )) V \ |
- |/ ` // ' \|
- ` V '
- */
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int kase=1;
- int t;
- cin>>t;
- while(t--)
- {
- deque<int>q;
- int a;
- string str,btr,temp;
- cin>>str>>btr;
- int s,b,i,j,sum=0,c=0,mod;
- if(btr.size()<str.size())swap(str,btr);
- s=str.size();
- b=btr.size();
- // cout<<" "<<str<<" "<<btr<<" ";
- j=s-1;
- for(i=b-1;i>=0;i--)
- {
- if(j>=0)
- {
- a=btr[i]-48+str[j]-48;
- sum=a+c;
- // cout<<"\n"<<sum<<" ";
- if(sum>9)c=1;
- else c=0;
- mod=sum%10;
- // cout<<mod;
- q.push_front(mod);
- j--;
- }
- else
- {
- a=btr[i]-48+c;
- mod=a%10;
- q.push_front(mod);
- if(a>9)c=1;
- else c=0;
- }
- }
- if(c==1)q.push_front(1);
- cout<<"Case #"<<kase++<<": ";
- for(auto x:q)
- {
- cout<<x;
- }
- cout<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement