## 10013 - Super long sums

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10013 - Super long sums

They mean the full integer is not 0.
For the first sample input, it's 463 + 4287
Check input and AC output for thousands of problems on uDebug!

sajib_only
New poster
Posts: 1
Joined: Sat Mar 21, 2015 12:59 am

### Re: 10013 - Super long sums

//why am i continuously getting RE?? //my code:

Code: Select all

``````#include <stdio.h>

int main()
{
int n, m;
int val, ex, i,j;
scanf("%d", &n);
while(n)
{
scanf("%d", &m);
int num1[m], num2[m];
int sum[m];
for(i=0; i<m; i++)
{
scanf("%d %d", &num1[i], &num2[i]);
}
ex=0;
i=m-1;
while(i>=0)
{
val=num1[i]+num2[i]+ex;
ex=0;
if(val<10) sum[i]=val;
else
{
ex++;
sum[i]=val-10;
}
i--;
}
if(ex)
{
printf("%d", ex);
for(i=0; i<m; i++) printf("%d", sum[i]);
putchar('\n');
}
else
{
for(i=0; i<m; i++)
{
if(sum[i]==0) continue;
else
{
for(j=i; j<m; j++) printf("%d", sum[j]);
putchar('\n');
break;
}
}
}
n--;

if(n) putchar('\n');
}
return 0;
}``````
Last edited by brianfry713 on Tue Mar 31, 2015 12:02 am, edited 1 time in total.

Tiramisu
New poster
Posts: 8
Joined: Fri Feb 20, 2015 10:28 am

### Re: 10013 - Super long sums

you have to dynamically allocate memory for such large arrays, so instead of int num1[m] num2[m]
do this:
int* num1 = new int;
int* num2 = new int;
when you are done with all computation free these arrays like:
delete[] num1;
delete[] num2;