Advertisement
Guest User

Problem 10474 - Where is the Marble? (Test generator)

a guest
Dec 14th, 2010
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.02 KB | None | 0 0
  1. /*
  2.     Problem 10474 - Where is the Marble? Test generator
  3.  
  4.     Compile and run:
  5.     javac Test.java
  6.     java Test > in.txt
  7.  
  8. */
  9.  
  10. import java.io.BufferedWriter;
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.io.OutputStreamWriter;
  14. import java.util.Random;
  15.  
  16. public class Test {
  17.     public static void main(String[] args) throws IOException{
  18.     BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 4096);
  19.     int MAX  = 10000;
  20.         int TEST = 64;
  21.         Random r = new Random();
  22.     for (int i = 0; i < TEST; i++){
  23.         int N = r.nextInt(MAX);
  24.         int Q = r.nextInt(MAX);
  25.         out.write(N + " " + Q + "\n"); 
  26.             for (int j = 1; j <= N; ++j) {
  27.                     int v = Math.abs(r.nextInt(MAX));
  28.             out.write(v + "\n");
  29.             }
  30.             for (int j = 1; j <= Q; ++j) {
  31.                     int v = Math.abs(r.nextInt(MAX));
  32.             out.write(v + "\n");
  33.             }
  34.     }
  35.     out.write("0 0\n");
  36.         out.flush();
  37.         out.close();
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement