AtCoder Beginner Contest 109

Submission #3594709

Source codeソースコード

#include<iostream>
#include<algorithm>
static const int MAX=10e5;
using namespace std;
int lcm(int a,int b){
	while(b!=0){
		int c=b;
		b=a%b;
		a=c;
	}
	return a;
}
int main(void)
{
	int N,M;
		cin >> N >> M;
	int X[MAX];
	for(int j=0,i=0;j<N;j++){
		int a;
			cin >> a;
		if(a>M && i==j)
			X[i++]=M;
		X[i++]=a;
	}
	sort(X,X+N+1);
	if(N==1){
		cout << X[N]-X[N-1] << endl;
		return 0;
	}
	
	int F=lcm(X[N]-X[N-1],X[N-1]-X[N-2]);
	for(int i=N-3;i>=0;i--)
		F=lcm(F,X[i+1]-X[i]);
	cout << F << endl;
	return 0;
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 300 hand_1,large_1,large_2,large_3,large_4,large_5,large_6,large_7,large_8,max_1,max_2,max_3,min_1,min_2,sample_01,sample_02,sample_03,small_1,small_2,small_3,small_4,small_5
Sample - sample_01,sample_02,sample_03

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
hand_1 AC 1 ms 256 KB
large_1 AC 10 ms 384 KB
large_2 AC 14 ms 384 KB
large_3 AC 11 ms 256 KB
large_4 AC 1 ms 256 KB
large_5 AC 1 ms 256 KB
large_6 AC 1 ms 256 KB
large_7 AC 1 ms 256 KB
large_8 AC 1 ms 256 KB
max_1 AC 61 ms 640 KB
max_2 AC 60 ms 640 KB
max_3 AC 61 ms 640 KB
min_1 WA
min_2 AC 1 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
small_1 AC 1 ms 256 KB
small_2 AC 1 ms 256 KB
small_3 AC 1 ms 256 KB
small_4 AC 1 ms 256 KB
small_5 WA