qwerty787788

Gen

Aug 6th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Gen {
  5.     FastScanner in;
  6.     PrintWriter out;
  7.  
  8.     Random rnd = new Random();
  9.  
  10.     void solve() {
  11.         int n = 1 + rnd.nextInt(100);
  12.         int m = 1 + rnd.nextInt(100);
  13.         out.println(n + " " + m);
  14.         char[] check = "0123456789".toCharArray();
  15.         for (int i = 0; i < n; i++) {
  16.             for (int j = 0; j < m; j++) {
  17.                 if(rnd.nextDouble() < 0.01) {
  18.                     out.print("#");
  19.                 } else
  20.                 out.print(check[rnd.nextInt(check.length)]);
  21.             }
  22.             out.println();
  23.         }
  24.     }
  25.  
  26.     void run() {
  27.         try {
  28.             out = new PrintWriter(new File("input.txt"));
  29.  
  30.             solve();
  31.  
  32.             out.close();
  33.         } catch (FileNotFoundException e) {
  34.             e.printStackTrace();
  35.         }
  36.     }
  37.  
  38.     void runIO() {
  39.  
  40.         in = new FastScanner(System.in);
  41.         out = new PrintWriter(System.out);
  42.  
  43.         solve();
  44.  
  45.         out.close();
  46.     }
  47.  
  48.     class FastScanner {
  49.         BufferedReader br;
  50.         StringTokenizer st;
  51.  
  52.         public FastScanner(File f) {
  53.             try {
  54.                 br = new BufferedReader(new FileReader(f));
  55.             } catch (FileNotFoundException e) {
  56.                 e.printStackTrace();
  57.             }
  58.         }
  59.  
  60.         public FastScanner(InputStream f) {
  61.             br = new BufferedReader(new InputStreamReader(f));
  62.         }
  63.  
  64.         String next() {
  65.             while (st == null || !st.hasMoreTokens()) {
  66.                 String s = null;
  67.                 try {
  68.                     s = br.readLine();
  69.                 } catch (IOException e) {
  70.                     e.printStackTrace();
  71.                 }
  72.                 if (s == null)
  73.                     return null;
  74.                 st = new StringTokenizer(s);
  75.             }
  76.             return st.nextToken();
  77.         }
  78.  
  79.         boolean hasMoreTokens() {
  80.             while (st == null || !st.hasMoreTokens()) {
  81.                 String s = null;
  82.                 try {
  83.                     s = br.readLine();
  84.                 } catch (IOException e) {
  85.                     e.printStackTrace();
  86.                 }
  87.                 if (s == null)
  88.                     return false;
  89.                 st = new StringTokenizer(s);
  90.             }
  91.             return true;
  92.         }
  93.  
  94.         int nextInt() {
  95.             return Integer.parseInt(next());
  96.         }
  97.  
  98.         long nextLong() {
  99.             return Long.parseLong(next());
  100.         }
  101.  
  102.         double nextDouble() {
  103.             return Double.parseDouble(next());
  104.         }
  105.     }
  106.  
  107.     public static void main(String[] args) {
  108.         new Gen().runIO();
  109.     }
  110. }
Add Comment
Please, Sign In to add comment