Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int OO = 1000000;
- ll mod = 1000000007;
- int main() {
- ios::sync_with_stdio(0);
- //freopen("out.txt" , "w" , stdout);
- int t;
- cin>>t;
- while(t--){
- int n;
- cin>>n;
- int a[n],b[n];
- for (int i=0 ; i<n ; i++)cin>>a[i]>>b[i];
- int ans[n];
- for(int i=n-1 ; i>=0 ; i--){
- int temp = a[i]+b[i];
- if(i==0){
- ans[i]=temp;
- }else {
- ans[i]= temp%10;
- temp/=10;
- a[i-1]+=temp;
- }
- }
- for(int i=0 ;i<n ; i++)cout<<ans[i];
- cout<<endl;
- if(t!=0 )cout<<endl;
- }
- }
Add Comment
Please, Sign In to add comment