AtCoder Grand Contest 010

Submission #1587282

Source codeソースコード

#include<cstdio>
int N,A[100010];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
bool calc(){
	bool s=0;
	int o=0;
	for(int i=0;i<N;i++)if(A[i]%2)o++;
	if(!o){
		for(int i=0;i<N;i++)A[i]/=2;
		return calc();
	}
	if(o==1&&N%2==1){
		int g=0;
		for(int i=0;i<N;i++)g=gcd(g,A[i]);
		for(int i=0;i<N;i++){
			if(A[i]==g)return 0;
			if(A[i]%2)A[i]-=g;
		}
		return!calc();
	}
	for(int i=0;i<N;i++)s^=(A[i]+1)%2;
	return s;
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",A+i);
	puts(calc()?"First":"Second");
}

Submission

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

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
^
./Main.cpp:26:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=0;i<N;i++)scanf("%d",A+i);
^

Test case

Set

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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
in1.txt AC 12 ms 512 KB
in10.txt AC 12 ms 512 KB
in11.txt AC 20 ms 512 KB
in12.txt AC 12 ms 512 KB
in13.txt AC 18 ms 512 KB
in14.txt AC 35 ms 512 KB
in15.txt AC 17 ms 512 KB
in16.txt AC 34 ms 512 KB
in17.txt AC 16 ms 512 KB
in18.txt AC 40 ms 512 KB
in19.txt AC 19 ms 512 KB
in2.txt AC 12 ms 512 KB
in20.txt AC 36 ms 512 KB
in21.txt AC 24 ms 512 KB
in22.txt AC 21 ms 512 KB
in23.txt AC 22 ms 512 KB
in24.txt AC 24 ms 512 KB
in25.txt AC 21 ms 512 KB
in26.txt AC 23 ms 512 KB
in27.txt AC 22 ms 512 KB
in28.txt AC 24 ms 512 KB
in29.txt AC 21 ms 512 KB
in3.txt AC 12 ms 512 KB
in30.txt AC 20 ms 512 KB
in31.txt AC 12 ms 512 KB
in32.txt AC 12 ms 512 KB
in33.txt AC 23 ms 512 KB
in34.txt AC 26 ms 512 KB
in35.txt AC 24 ms 512 KB
in36.txt AC
in37.txt AC
in4.txt AC 12 ms 512 KB
in5.txt AC 12 ms 512 KB
in6.txt AC 12 ms 512 KB
in7.txt AC 12 ms 512 KB
in8.txt AC 12 ms 512 KB
in9.txt AC 12 ms 512 KB
sample1.txt AC
sample2.txt AC
sample3.txt AC