Submission #8416016


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;
        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 0
Code Size 3024 Byte
Status WA
Exec Time 79 ms
Memory 24800 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 17
WA × 2
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 21 ms 9172 KB
sample_03.txt AC 22 ms 11220 KB
sample_04.txt AC 22 ms 11220 KB
subtask_1_01.txt AC 22 ms 13268 KB
subtask_1_02.txt AC 22 ms 11220 KB
subtask_1_03.txt AC 79 ms 22488 KB
subtask_1_04.txt AC 68 ms 22368 KB
subtask_1_05.txt AC 48 ms 17760 KB
subtask_1_06.txt WA 30 ms 12896 KB
subtask_1_07.txt AC 57 ms 24800 KB
subtask_1_08.txt AC 65 ms 21344 KB
subtask_1_09.txt WA 45 ms 18912 KB
subtask_1_10.txt AC 62 ms 19680 KB
subtask_1_11.txt AC 62 ms 22624 KB