No... I got AC now! It's only that TL is really tight.
What I changed was - now Im printing nines not one by one. Now I print them in groups '9999' + '9999' .... Same with zeros '0000'+... Strange but is decreased my Run Time by over 2secs.
I think that If memory limit for this problem was 64K and time limit was a little greater... the problem would only gain from it. Seems like they ve taken it from timus without seeing where is the "cream".
my output is ok for this input.But i got WA (in 22 times)can any body help
me?what is my problem in my code i have use unsigned long.i have also solve 583 but in this problem i got WA.I am really tired for this problem.
I think you don't treat the carry for the most significant cypher correctly.
Try to change your loop this way:
[c]
a[0]=0;
for(j=1;j<=m;j++)
[/c]
and later on, when printf-ing:
[c]
for(;j<=m;j++)
[/c]
This leaves room for an extra digit at index 0.
Oh, don't forget to add room for another extra digit in your array...
yet i got wa.in problem it was told the sum will be no longer than the given integer.so why extra place.i think there is problem in taking input.
plssss will you check
Salmin Sultana wrote:yet i got wa.in problem it was told the sum will be no longer than the given integer.so why extra place.i think there is problem in taking input.
plssss will you check
Sorry for not checking the problem first...
anyway the prob with your prog is in the output:
for (i = len; i > 0; i--){
sum1 = sum2 = 0;
for (j = 0; j < 8; j++){
scanf("%ld%ld", &x1, &x2);
sum1 = sum1*10+x1;
sum2 = sum2*10+x2;
}
a = sum1;
b = sum2;
}
if (m%8 != 0){
++len;
}
for (i = 1; i <= len; i++){
a += b;
}
for (i = 1; i <= len; i++){
if (a >= CARRY){
a[i+1] += a/CARRY;
a %= CARRY;
}
}
if (a[len+1]!=0){
++len;
}
printf("%ld", a[len]);
for (i = len-1; i > 0; i--){
printf("%08ld", a);
}
printf("\n");
if (casei < casen-1){
printf("\n");
}
}