|
|
back to boardWA#4.Where is my mistake? import java.io.*; class Assert { static void check(boolean e) { if (!e) { throw new Error(); } } } class Scanner { StreamTokenizer in; Scanner(InputStream is) { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is))); in.resetSyntax(); in.whitespaceChars(0, 32); in.wordChars(33, 255); } String next() { try { in.nextToken(); Assert.check(in.ttype == in.TT_WORD); return in.sval; } catch (IOException e) { throw new Error(e); } } int nextInt() { return Integer.parseInt(next()); } } public class Main { PrintWriter out; Scanner in; void solve() { int n = in.nextInt(); int a = in.nextInt() + in.nextInt(); int b; for (int i = 1; i < n; i++) { b = in.nextInt() + in.nextInt(); out.print(a + b / 10); a = b % 10; } out.print(a); } void run() { in = new Scanner(System.in); out = new PrintWriter(System.out); try { solve(); } finally { out.close(); } } public static void main(String[] args) { new Main().run(); } } Re: WA#4.Where is my mistake? I tried it without exceptions, and I got TLE. try this test : 3 1 0 8 1 9 1 Try using java.util.Scanner and remove the two first classes. Edited by author 28.03.2011 20:08 |
|
|