Page 6 of 15
Posted: Mon Jun 07, 2004 1:28 pm
to alu_mathics,

in my opinion your last example is not correct. The problem statement says that the length of the sum does not exceed M. As M is 1, the answer 17 should not occur!

Haven't been accepted yet, so I'm not 100% certain but that's how I understand that sentence.

Bye

Posted: Wed Jun 23, 2004 5:13 pm
I am getting Wrong answer again again, when all the input output seem to be Ok!  Here is my code:
[cpp]
I wait for three days but No Body help me so I remove the code!
[/cpp]

what will be output for this input:

Code: Select all

``````1
2
9 9
9 9
``````

Posted: Tue Jun 29, 2004 7:29 am
You have work hard for a easy problem! It is just adding , read two digit and add them if carry or if result of this two is greater then 9 then store 1 for next pair of digit . so its is as easy as primary calculation. Just use char string to store result (no need to use long array) ### 10013 Accepted (P.E.)

Posted: Tue Aug 03, 2004 1:11 pm
who can help me? Thanks

Code: Select all

``````# include <stdio.h>
int main()
{
long i,j,n,m;
int num;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
getchar();
scanf("%ld",&m);
for(j=0;j<m;j++)
scanf("%d%d",&num[j],&num[j]);
for(j=m-1;j>=0;j--)
{
if(num[j]+num[j]>=10)
{
num[j]=num[j]+num[j]-10;
num[j-1]=num[j-1]+1;
}
else
num[j]=num[j]+num[j];
}
for(j=0;j<m;j++)
printf("%d",num[j]);
printf("\n");
printf("\n");
}
return 0;
}``````

### oopsi daisy

Posted: Tue Aug 03, 2004 2:58 pm
Hi,

The problem statement says that there is a blank line between two cases...
... which means there is no line after the very last case. [c]
for(j=0;j<m;j++)
printf("%d",num[j]);
printf("\n");
printf("\n");
[/c]

The second newline is not always necessary..

change this part of your code to

[c]
for(j=0;j<m;j++)
printf("%d",num[j]);
printf("\n");
if(i<n-1)
printf("\n");
[/c]

Hope it helps. ### Thanks

Posted: Wed Aug 04, 2004 3:36 am
sohel,Thank you indeed!
I got AC but no ( P.E.) ### thank you very much

Posted: Sat Aug 07, 2004 11:25 am
I've got AC~thank you very much~

but I am still wondering where the bug is~hahahaha

### 10013 Why P.E

Posted: Sun Sep 26, 2004 8:43 am

#include<stdio.h>

long long n,i;
long m,j,k,sum,l;
int fd1,data1,data2,sum1,d,fd;

void main()
{
scanf("%lld",&n);
printf("\n");
while(i<n)
{
scanf("%ld",&m);
if(m<1||m>1000000)
break;
for(j=0;j<m;j++)
{
scanf("%d",&data1[j]);
scanf("%d",&data2[j]);
}
for(k=j-1;k>=0;k--)
{
sum=data1[k]+data2[k]+fd;
fd=0;
if(sum>=10)
{
d=sum%10;
sum=d;
fd=1;
}
sum1[l]=sum;
l++;
}
if(fd==1)
{
sum1[l]=fd;
l++;
}
for(j=l-1;j>=0;j--)
printf("%d",sum1[j]);
l=0;
fd=0;
i++;
if(i<n)
printf("\n\n");
}
}

Posted: Sun Sep 26, 2004 10:26 am
Don't work hard with PE code I think One should not post their accepted code here Posted: Sun Sep 26, 2004 2:00 pm
Probable you must not put a blank line after last case e.g printf("\n\n").
You can write in this way:

while(i < n)
{
/* ...... */
if(i == n)
printf("\n");
else
printf("\n\n");
}

### Again P.E

Posted: Tue Sep 28, 2004 7:52 am
"while(i < n)
{
/* ...... */
if(i == n)
printf("\n");
else
printf("\n\n");
}"

But Same P.E

Posted: Wed Sep 29, 2004 6:29 am
1
9
8

Posted: Thu Sep 30, 2004 10:23 am
Oh... I've forgot
Delete the line
printf("\n")
before while(i<n) from your source code and you'll get a clean AC.

### 10013, Igot WA. WHY?????????????? I NEAD HELP!!!

Posted: Fri Oct 29, 2004 1:10 pm
Please, i nead help. Can someone pleas help me. I send my code and i always get WA.
If i have input:
1

3
1 2
4 5
5 5

the output is:
3100

and i don't know haw to make this right.

Here is my code in JAVA:

[java]

Code: Select all

``````import java.io.*;
import java.util.*;

class Super_long_sums
{
static String ReadLn (int maxLg)  // utility function to read from stdin
{
byte lin[] = new byte [maxLg];
int lg = 0, car = -1;
String line = "";

try
{
while (lg < maxLg)
{
if ((car < 0) || (car == '\n')) break;
lin [lg++] += car;
}
}
catch (IOException e)
{
return (null);
}
if ((car < 0) && (lg == 0)) return (null);  // eof
return (new String (lin, 0, lg));
}

public static void main (String args[])  // entry point from OS
{
Main myWork = new Main();  // create a dinamic instance
myWork.Begin();            // the true entry point
}
void Begin()
{
String input;
StringTokenizer idata;
int N;
int stevec = 0;
int M = 0;
int prenesi = 0;
N = Integer.parseInt(input.trim());

while (stevec<N)
{
M = Integer.parseInt(input.trim());
if((N == 0) &&(M == 0))break;
int tab1 [] = new int[M];
int tab2 [] = new int[M];
int rezultat [] = new int[M];
for (int i=0; i <= M; i++)
{
idata = new StringTokenizer (input.trim());
tab1[i] = Integer.parseInt(idata.nextToken());
tab2[i] = Integer.parseInt(idata.nextToken());
rezultat[i] = tab1[i] + tab2[i] + prenesi;
if(i>0 && rezultat[i] > 9){
prenesi = 1;
rezultat[i] = rezultat[i]%10;
rezultat[i-1] = rezultat[i-1]+1;
}//if
else{
prenesi = 0;
}//else
}//for
stevec++;
if(rezultat > 9){
break;
}
else{
System.out.println();
for(int k = 0; k < M; k++){
System.out.print(rezultat[k]);
}
}
System.out.println();
System.out.println();
} //while
} //Begin()

} //class[/java]

:oops:  :oops:  :oops:

Plese help me!!!!! Thank you!!!! :D  :D``````

Posted: Sat Oct 30, 2004 11:02 am
For
1

3
1 2
4 5
5 5

My Accepted Code output is :

400