Submission #8416027
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = sc.ReadInt(); var K = sc.ReadInt(); var A = sc.ReadIntArray(N); var ok = true; if (A.Max() < K) { Console.WriteLine("IMPOSSIBLE"); return; } if (A.Contains(K)) { Console.WriteLine("POSSIBLE"); return; } long gcd = A[0]; for (int i = 1; i < N; i++) { gcd = Gcd(gcd, A[i]); } ok = gcd == 1 || K % gcd == 0; Console.WriteLine(ok ? "POSSIBLE" : "IMPOSSIBLE"); } static long Gcd(long a, long b) { var v = new[] { a, b }; while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; } return v[0]; } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } }
Submission Info
Submission Time | |
---|---|
Task | A - Getting Difference |
User | TM999TM |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 3040 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 26584 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 | 22 ms | 11220 KB |
sample_02.txt | AC | 22 ms | 11220 KB |
sample_03.txt | AC | 22 ms | 13268 KB |
sample_04.txt | AC | 20 ms | 9172 KB |
subtask_1_01.txt | AC | 22 ms | 11220 KB |
subtask_1_02.txt | AC | 21 ms | 11220 KB |
subtask_1_03.txt | AC | 80 ms | 26584 KB |
subtask_1_04.txt | AC | 68 ms | 22368 KB |
subtask_1_05.txt | AC | 46 ms | 18016 KB |
subtask_1_06.txt | AC | 30 ms | 12896 KB |
subtask_1_07.txt | AC | 57 ms | 20704 KB |
subtask_1_08.txt | AC | 64 ms | 21472 KB |
subtask_1_09.txt | AC | 46 ms | 20960 KB |
subtask_1_10.txt | AC | 63 ms | 21728 KB |
subtask_1_11.txt | AC | 61 ms | 22624 KB |