10013 - Super long sums
Moderator: Board moderators
10013 wa! Please help
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:


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
-
- New poster
- Posts: 13
- Joined: Tue Aug 03, 2004 4:24 am
- Location: CHINA
10013 Accepted (P.E.)
who can help me? Thanks
Code: Select all
# include <stdio.h>
int main()
{
long i,j,n,m;
int num[1000000][2];
scanf("%ld",&n);
for(i=0;i<n;i++)
{
getchar();
scanf("%ld",&m);
for(j=0;j<m;j++)
scanf("%d%d",&num[j][0],&num[j][1]);
for(j=m-1;j>=0;j--)
{
if(num[j][0]+num[j][1]>=10)
{
num[j][0]=num[j][0]+num[j][1]-10;
num[j-1][0]=num[j-1][0]+1;
}
else
num[j][0]=num[j][0]+num[j][1];
}
for(j=0;j<m;j++)
printf("%d",num[j][0]);
printf("\n");
printf("\n");
}
return 0;
}
oopsi daisy
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.
A portion of your code
[c]
for(j=0;j<m;j++)
printf("%d",num[j][0]);
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][0]);
printf("\n");
if(i<n-1)
printf("\n");
[/c]
Hope it helps.
The problem statement says that there is a blank line between two cases...
... which means there is no line after the very last case.

A portion of your code
[c]
for(j=0;j<m;j++)
printf("%d",num[j][0]);
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][0]);
printf("\n");
if(i<n-1)
printf("\n");
[/c]
Hope it helps.

-
- New poster
- Posts: 13
- Joined: Tue Aug 03, 2004 4:24 am
- Location: CHINA
Thanks
sohel,Thank you indeed!
I got AC but no ( P.E.)
I got AC but no ( P.E.)

thank you very much
I've got AC~thank you very much~
but I am still wondering where the bug is~hahahaha
but I am still wondering where the bug is~hahahaha
10013 Why P.E
/*Why 10013 got Pe Please Help*/
#include<stdio.h>
long long n,i;
long m,j,k,sum,l;
int fd1,data1[1000000],data2[1000000],sum1[1000000],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");
}
}
#include<stdio.h>
long long n,i;
long m,j,k,sum,l;
int fd1,data1[1000000],data2[1000000],sum1[1000000],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");
}
}
10013, Igot WA. WHY?????????????? I NEAD HELP!!!
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]
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)
{
car = System.in.read();
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;
input = Main.ReadLn (255);
N = Integer.parseInt(input.trim());
input = Main.ReadLn (255);
while (stevec<N)
{
input = Main.ReadLn (255);
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++)
{
input = Main.ReadLn (255);
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[0] > 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