Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int OO = 1000000;
  5. ll mod = 1000000007;
  6.  
  7.  
  8. int main() {
  9. ios::sync_with_stdio(0);
  10. //freopen("out.txt" , "w" , stdout);
  11. int t;
  12. cin>>t;
  13. while(t--){
  14. int n;
  15. cin>>n;
  16. int a[n],b[n];
  17. for (int i=0 ; i<n ; i++)cin>>a[i]>>b[i];
  18. int ans[n];
  19. for(int i=n-1 ; i>=0 ; i--){
  20. int temp = a[i]+b[i];
  21. if(i==0){
  22. ans[i]=temp;
  23. }else {
  24. ans[i]= temp%10;
  25. temp/=10;
  26. a[i-1]+=temp;
  27. }
  28. }
  29. for(int i=0 ;i<n ; i++)cout<<ans[i];
  30. cout<<endl;
  31. if(t!=0 )cout<<endl;
  32. }
  33. }
Add Comment
Please, Sign In to add comment