-
Notifications
You must be signed in to change notification settings - Fork 14
/
10013.cpp
32 lines (32 loc) · 920 Bytes
/
10013.cpp
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
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
int test,i;
scanf("%d",&test);
for(i=0;i<test;i++){
int n,j;
scanf("%d",&n);
int sum[n], carry=0;
memset(sum, 0, sizeof(sum));
for(j=0; j<n; j++){
int a=0, b=0;
scanf("%d%d",&a,&b);
sum[j] = a + b;
}
for(j=n-1 ;j>=0; j--){
int temp = sum[j];
sum[j] = (temp+carry)%10;
carry = (temp+carry)/10;
}
for(j=0;j<n;j++)
printf("%d",sum[j]);
printf("\n");
if(i < test-1)
printf("\n");
}
//system("pause");
return 0;
}