Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
1,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintWriter;
  5. import java.util.StringTokenizer;
  6.  
  7. public class Primes {
  8.     private void solve() throws IOException {
  9.         int n = readInt();
  10.         out.println(n / 2);
  11.         while (n > 3) {
  12.             out.print(2 + " ");
  13.             n -= 2;
  14.         }
  15.         out.println(n);
  16.     }
  17.  
  18. //------------------------------------------------------------------------------
  19.     public static void main(String[] args) {
  20.         new Primes().run();
  21.     }
  22.  
  23.     private void run() {
  24.         try {
  25.             initIO();
  26.             solve();
  27.             in.close();
  28.             out.close();
  29.         } catch (Throwable e) {
  30.             throw new RuntimeException(e);
  31.         }
  32.     }
  33.  
  34.     private BufferedReader in;
  35.     private StringTokenizer tok;
  36.     private PrintWriter out;
  37.  
  38.     private void initIO() throws IOException {
  39.         in = new BufferedReader(new InputStreamReader(System.in));
  40.         out = new PrintWriter(System.out);
  41. //        in = new BufferedReader(new FileReader(new File("input.txt")));
  42. //        out = new PrintWriter(new File("output.txt"));
  43.     }
  44.  
  45.     private String readString() throws IOException {
  46.         while (tok == null || !tok.hasMoreTokens()) {
  47.             tok = new StringTokenizer(in.readLine());
  48.         }
  49.         return tok.nextToken();
  50.     }
  51.  
  52.     @SuppressWarnings("unused")
  53.     private int readInt() throws IOException {
  54.         return Integer.parseInt(readString());
  55.     }
  56.  
  57.     @SuppressWarnings("unused")
  58.     private long readLong() throws IOException {
  59.         return Integer.parseInt(readString());
  60.     }
  61.  
  62.     @SuppressWarnings("unused")
  63.     private double readDouble() throws IOException {
  64.         return Double.parseDouble(readString());
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement