Submission #1093276


Source Code Expand

Copy
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    int N;
    public bool calc2(long[] A)
    {
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += A[i];
        }
        if ((sum - N) % 2 == 1) return true;
        if (N % 2 == 0) return false;

        int oddcnt = 0;
        int oddpos = -1;
        for (int i = 0; i < N; i++)
        {
            if(A[i] % 2 == 1)
            {
                oddpos = i;
                oddcnt++;
            }
        }

        if (oddcnt != 1) return false;
        if (A[oddpos] == 1) return false;
        A[oddpos]--;

        long g = A[0];
        for (int i = 1; i < N; i++)
        {
            g = gcd(A[i], g);
        }
        for (int i = 0; i < N; i++)
        {
            A[i] /= g;
        }

        return !calc2(A);
    }

    long gcd(long a, long b)
    {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public void calc()
    {
        long[] A;
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        if (calc2(A)) Console.WriteLine("First");
        else Console.WriteLine("Second");
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Submission Info

Submission Time
Task D - Decrementing
User chokudai
Language C# (Mono 4.6.2.0)
Score 1000
Code Size 2341 Byte
Status
Exec Time 153 ms
Memory 16472 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 1000 / 1000 sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt
Case Name Status Exec Time Memory
in1.txt 79 ms 16472 KB
in10.txt 77 ms 16344 KB
in11.txt 101 ms 16344 KB
in12.txt 77 ms 16344 KB
in13.txt 94 ms 16344 KB
in14.txt 139 ms 16216 KB
in15.txt 91 ms 16344 KB
in16.txt 136 ms 16344 KB
in17.txt 88 ms 16344 KB
in18.txt 153 ms 16344 KB
in19.txt 95 ms 14936 KB
in2.txt 77 ms 16344 KB
in20.txt 140 ms 15320 KB
in21.txt 105 ms 16472 KB
in22.txt 105 ms 16472 KB
in23.txt 102 ms 16472 KB
in24.txt 106 ms 16472 KB
in25.txt 100 ms 16088 KB
in26.txt 103 ms 16472 KB
in27.txt 103 ms 16088 KB
in28.txt 109 ms 16472 KB
in29.txt 100 ms 16088 KB
in3.txt 78 ms 16344 KB
in30.txt 102 ms 16472 KB
in31.txt 78 ms 16344 KB
in32.txt 78 ms 16344 KB
in33.txt 102 ms 16216 KB
in34.txt 110 ms 16472 KB
in35.txt 104 ms 16344 KB
in36.txt 20 ms 2648 KB
in37.txt 20 ms 2648 KB
in4.txt 78 ms 16344 KB
in5.txt 77 ms 16344 KB
in6.txt 78 ms 16344 KB
in7.txt 77 ms 16344 KB
in8.txt 78 ms 16344 KB
in9.txt 79 ms 16344 KB
sample1.txt 20 ms 2648 KB
sample2.txt 20 ms 2648 KB
sample3.txt 20 ms 2648 KB