AtCoder Grand Contest 010

Submission #1357207

Source codeソースコード

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,a[100010];

int gcd(int a, int b){
    if (!b) return a;
    return gcd(b,a%b);
}

bool get_ans(){
    int cnte=0,i,gc=0;
    for (i=1; i<=N; i++){
        if (a[i]%2==0) cnte++;

    }

    if (cnte%2) return 1;
    else if (N-cnte>1) return 1;
    else {
        for (i=1; i<=N; i++){
            if (a[i]%2) a[i]--;
            gc=gcd(a[i],gc);
        }
        for (i=1; i<=N; i++)
            a[i]/=gc;

        return !get_ans();
    }
}
int main(){
    cin >> N;

    int i;
    for (i=1; i<=N; i++)
        cin >> a[i];

    bool ans=get_ans();
    if (ans) cout << "First\n";
    else cout << "Second\n";

    return 0;
}

Submission

Task問題 D - Decrementing
User nameユーザ名 yosei-san
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 960 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt
All 0 / 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,sample1.txt,sample2.txt,sample3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 53 ms 640 KB
in10.txt AC 54 ms 640 KB
in11.txt WA
in12.txt AC 54 ms 640 KB
in13.txt AC 56 ms 640 KB
in14.txt AC 67 ms 640 KB
in15.txt AC 56 ms 640 KB
in16.txt AC 67 ms 640 KB
in17.txt WA
in18.txt AC 70 ms 640 KB
in19.txt WA
in2.txt AC 54 ms 640 KB
in20.txt WA
in21.txt WA
in22.txt WA
in23.txt WA
in24.txt WA
in25.txt WA
in26.txt WA
in27.txt WA
in28.txt WA
in29.txt WA
in3.txt AC 54 ms 640 KB
in30.txt WA
in31.txt WA
in32.txt WA
in33.txt AC 59 ms 640 KB
in34.txt AC 61 ms 640 KB
in35.txt AC 60 ms 640 KB
in36.txt RE
in37.txt AC 1 ms 256 KB
in4.txt AC 53 ms 640 KB
in5.txt WA
in6.txt WA
in7.txt AC 54 ms 640 KB
in8.txt AC 53 ms 640 KB
in9.txt AC 54 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB