Adding some more judges, here and there.
[and.git] / NEERC / zero / zero_re.java
blobb3ecdd86965ced334a47cd28bc646eeae45a2b26
1 /*
2 Solution for NEERC'2005 Problem Z: Zero-complexity Transposition
3 (C) Roman Elizarov
4 Note: this solution attempts to check correctness of the input
5 */
7 import java.io.BufferedReader;
8 import java.io.FileReader;
9 import java.io.FileWriter;
10 import java.io.PrintWriter;
11 import java.util.StringTokenizer;
13 public class zero_re {
14 static final int MAXN = 10000;
15 static final long MAXABS = 1000000000000000L;
17 public static void main(String[] args) throws Exception {
18 // Read input
19 BufferedReader in = new BufferedReader(new FileReader("zero.in"));
20 int n = Integer.parseInt(in.readLine());
21 if (n < 1 || n > MAXN)
22 throw new IllegalArgumentException("n is out of range");
23 long[] a = new long[n];
24 StringTokenizer st = new StringTokenizer(in.readLine());
25 for (int i = 0; i < n; i++) {
26 a[i] = Long.parseLong(st.nextToken());
27 if (Math.abs(a[i]) > MAXABS)
28 throw new IllegalArgumentException("a[i] is out of range");
30 if (st.hasMoreTokens())
31 throw new IllegalArgumentException("Extra data on line");
32 if (in.readLine() != null)
33 throw new IllegalArgumentException("Extra data in file");
34 in.close();
36 // Write output
37 PrintWriter out = new PrintWriter(new FileWriter("zero.out"));
38 String sep = "";
39 for (int i = n; --i >= 0;) {
40 out.print(sep);
41 sep = " ";
42 out.print(a[i]);
44 out.close();