Submission #2851470


Source Code Expand

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static boolean debug = false;

	static void solve() {
		int n = ir.nextInt();
		if (n == 3) {
			out.println("2 5 63");
			return;
		}
		ArrayList<Integer> m = new ArrayList<>();
		m.add(2);
		m.add(3);
		m.add(4);
		for (int i = 6; i <= 30000; i++)
			if (i % 2 == 0 || i % 3 == 0)
				m.add(i);
		if (n % 8 == 4 || n % 8 == 3) {
			for (int i = 0; i < n; i++) {
				if (i == n - 2)
					continue;
				out.print(m.get(i) + " ");
			}
			out.println(m.get(n));
		} else if (n % 8 == 5 || n % 8 == 2) {
			{
				for (int i = 0; i < n - 1; i++) {
					out.print(m.get(i) + " ");
				}
				out.println(m.get(n));
			}
		} else if (n % 8 == 6 || n % 8 == 1) {
			for (int i = 0; i < n; i++) {
				if (i == n - 2)
					continue;
				out.print(m.get(i) + " ");
			}
			out.println(m.get(n + 1));
		} else {
			for (int i = 0; i < n; i++) {
				out.print(m.get(i) + (i == n - 1 ? "\n" : " "));
			}
		}
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		if (debug)
			out.println(Arrays.deepToString(o));
	}
}

Submission Info

Submission Time
Task B - GCD Sequence
User holeguma
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 4148 Byte
Status WA
Exec Time 114 ms
Memory 28628 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 1
WA × 1
AC × 36
WA × 4
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 111 ms 25556 KB
02.txt AC 73 ms 19156 KB
03.txt AC 74 ms 20564 KB
04.txt AC 72 ms 18260 KB
05.txt AC 73 ms 18900 KB
06.txt AC 73 ms 19412 KB
07.txt AC 73 ms 18900 KB
08.txt AC 73 ms 18260 KB
09.txt WA 74 ms 18644 KB
10.txt AC 74 ms 18772 KB
11.txt AC 73 ms 18004 KB
12.txt AC 72 ms 19540 KB
13.txt AC 73 ms 18900 KB
14.txt AC 73 ms 18004 KB
15.txt AC 74 ms 21332 KB
16.txt AC 110 ms 24276 KB
17.txt AC 113 ms 24532 KB
18.txt AC 110 ms 26580 KB
19.txt AC 109 ms 26452 KB
20.txt WA 97 ms 23636 KB
21.txt AC 108 ms 25044 KB
22.txt AC 106 ms 26452 KB
23.txt AC 108 ms 23636 KB
24.txt AC 111 ms 23892 KB
25.txt AC 114 ms 26836 KB
26.txt AC 110 ms 28628 KB
27.txt AC 110 ms 22996 KB
28.txt WA 111 ms 23508 KB
29.txt AC 114 ms 24276 KB
30.txt AC 112 ms 26196 KB
31.txt AC 114 ms 23636 KB
32.txt AC 91 ms 19284 KB
33.txt AC 75 ms 19284 KB
34.txt AC 102 ms 23380 KB
35.txt AC 106 ms 22228 KB
36.txt AC 99 ms 21460 KB
37.txt AC 112 ms 26708 KB
38.txt AC 94 ms 20948 KB
s1.txt AC 70 ms 18388 KB
s2.txt WA 74 ms 16468 KB