Submission #1445308
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.Reader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author tanzaku */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; MyInput in = new MyInput(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { public void solve(int testNumber, MyInput in, PrintWriter out) { int n = in.nextInt(); int k = in.nextInt(); int[] a = in.nextIntArray(n); int g = 0; for (int i = 0; i < n; i++) g = gcd(g, a[i]); for (int i = 0; i < n; i++) { if (k <= a[i] && (a[i] - k) % g == 0) { out.println("POSSIBLE"); return; } } out.println("IMPOSSIBLE"); } static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n % r); } } static class MyInput { private final BufferedReader in; private static int pos; private static int readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500 * 8 * 2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for (int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public MyInput(InputStream is) { in = new BufferedReader(new InputStreamReader(is)); } public int read() { if (pos >= readLen) { pos = 0; try { readLen = in.read(buffer); } catch (IOException e) { throw new RuntimeException(); } if (readLen <= 0) { throw new MyInput.EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if (str[0] == '-') { i = 1; } for (; i < len; i++) ret = ret * 10 + str[i] - '0'; if (str[0] == '-') { ret = -ret; } return ret; } public char nextChar() { while (true) { final int c = read(); if (!isSpace[c]) { return (char) c; } } } int reads(int len, boolean[] accept) { try { while (true) { final int c = read(); if (accept[c]) { break; } if (str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char) c; } } catch (MyInput.EndOfFileRuntimeException e) { } return len; } public int[] nextIntArray(final int n) { final int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } static class EndOfFileRuntimeException extends RuntimeException { } } }
Submission Info
Submission Time | |
---|---|
Task | A - Getting Difference |
User | tanzaku |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 4393 Byte |
Status | AC |
Exec Time | 132 ms |
Memory | 23764 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 70 ms | 19412 KB |
sample_02.txt | AC | 69 ms | 19412 KB |
sample_03.txt | AC | 68 ms | 18516 KB |
sample_04.txt | AC | 69 ms | 17748 KB |
subtask_1_01.txt | AC | 67 ms | 21460 KB |
subtask_1_02.txt | AC | 69 ms | 21332 KB |
subtask_1_03.txt | AC | 132 ms | 21588 KB |
subtask_1_04.txt | AC | 116 ms | 23380 KB |
subtask_1_05.txt | AC | 113 ms | 22740 KB |
subtask_1_06.txt | AC | 101 ms | 23764 KB |
subtask_1_07.txt | AC | 107 ms | 21588 KB |
subtask_1_08.txt | AC | 116 ms | 22228 KB |
subtask_1_09.txt | AC | 110 ms | 20692 KB |
subtask_1_10.txt | AC | 115 ms | 20180 KB |
subtask_1_11.txt | AC | 123 ms | 21956 KB |