10013 stil got WA!!!!Please!!!!
Posted: Sun Oct 31, 2004 1:11 am
I change my code, but i stil get WA and i don't know why???
My new code is:
JAVA:
My new code is:
JAVA:
Code: Select all
[java]
/* @JUDGE_ID: 50020MM 10035 java */
import java.io.*;
import java.util.*;
class Main
{
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;
int vsota = 0;
int stevilo = 0;
input = Main.ReadLn (255);
N = Integer.parseInt(input.trim());
input = Main.ReadLn (255);
while (stevec < N)
{
prenesi = 0;
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());
int a = Integer.parseInt(idata.nextToken());
int b = Integer.parseInt(idata.nextToken());
vsota = a + b;
rezultat[i] = vsota;
}//for
for(int i = M-1; i >= 0; i--){
rezultat[i] = rezultat[i]+prenesi;
if((rezultat[i]) >= 10){
prenesi = 1;
rezultat[i] = rezultat[i]%10;
}//if
else{
rezultat[i] = rezultat[i];
prenesi = 0;
}//else
}//for
stevec++;
System.out.println();
for(int k = 0; k < M; k++){
System.out.print(rezultat[k]);
}
System.out.println("\n");
} //while
} //Begin()
} //class
/* @END_OF_SOURCE_CODE */
[/java]
Do you have to read all the blocks and then you print the answer, or you read one block at the time. Can you do like this???
input
2
4
1 2
3 4
5 5
4 1
output
3805
input
3
9 8
6 2
1 1
output
782
Thank you for you help!!!!
:D :D :D