結果

問題 No.1884 Sequence
ユーザー publflpublfl
提出日時 2022-03-25 21:31:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 57,184 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2024-04-22 06:07:39
合計ジャッジ時間 3,469 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 58 ms
5,452 KB
testcase_11 AC 59 ms
5,376 KB
testcase_12 AC 16 ms
5,376 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 39 ms
5,376 KB
testcase_16 AC 58 ms
5,712 KB
testcase_17 AC 27 ms
5,376 KB
testcase_18 AC 33 ms
5,376 KB
testcase_19 AC 28 ms
5,376 KB
testcase_20 AC 35 ms
5,376 KB
testcase_21 AC 28 ms
5,376 KB
testcase_22 AC 37 ms
5,376 KB
testcase_23 AC 58 ms
5,584 KB
testcase_24 AC 58 ms
5,580 KB
testcase_25 AC 57 ms
5,580 KB
testcase_26 AC 59 ms
5,452 KB
testcase_27 AC 18 ms
5,376 KB
testcase_28 AC 18 ms
5,376 KB
testcase_29 AC 18 ms
5,376 KB
testcase_30 AC 19 ms
5,376 KB
testcase_31 AC 31 ms
5,376 KB
testcase_32 AC 53 ms
5,376 KB
testcase_33 AC 42 ms
5,576 KB
testcase_34 AC 41 ms
5,580 KB
testcase_35 AC 20 ms
5,376 KB
testcase_36 AC 33 ms
5,376 KB
testcase_37 AC 41 ms
5,576 KB
testcase_38 AC 39 ms
5,448 KB
testcase_39 AC 24 ms
5,376 KB
testcase_40 AC 25 ms
5,376 KB
testcase_41 AC 49 ms
5,580 KB
testcase_42 AC 49 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
#include <algorithm>

long long int gcd(long long int a, long long int b)
{
	return a?gcd(b%a,a):b;
}

std::vector<long long int> V;
int main()
{
	int a;
	scanf("%d",&a);
	int count = 0;
	for(int i=1;i<=a;i++)
	{
		long long int b;
		scanf("%lld",&b);
		if(b==0) count++;
		else V.push_back(b);
	}
	std::sort(V.begin(),V.end());
	if(V.size()<=1) printf("Yes");
	else
	{
		int control1 = 0, control2 = 0;
		for(int i=1;i<V.size();i++)
		{
			if(V[i]==V[i-1]) control1 = 1;
			else control2 = 1;
		}
		if(control1==1)
		{
			if(control2==1) printf("No");
			else printf("Yes");
			return 0;
		}
		
		long long int g = 0;
		long long int C = 0;
		for(int i=1;i<V.size();i++) g = gcd(g,V[i]-V[i-1]);
		for(int i=1;i<V.size();i++) C += (V[i]-V[i-1]-1)/g;
		if(C<=count) printf("Yes");
		else printf("No");
	}
}
0