結果

問題 No.1884 Sequence
ユーザー lanegue
提出日時 2022-03-25 21:53:29
言語 D
(dmd 2.109.1)
結果
RE  
実行時間 -
コード長 409 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 180,076 KB
実行使用メモリ 13,384 KB
最終ジャッジ日時 2024-06-22 14:41:16
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 RE * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`

ソースコード

diff #

import std;

void main(){
	auto n = readln.chomp.to!int;
	auto a = readln.chomp.split.to!(int[]);
	auto b = a.filter!(x => x != 0).array.sort;
	if(b.length < 2){
		writeln("Yes");
		return;
	}
	auto m = b[1] - b[0];
	for(auto i = 1; i < b.length - 1; i++){
		auto d = b[i + 1] - b[i];
		m = m.gcd(d);
	}
	stderr.writeln(m);
	if(b[$ - 1] - b[0] <= m * (n - 1)){
		writeln("Yes");
	}else{
		writeln("No");
	}
}
0