結果

問題 No.1884 Sequence
ユーザー lanegue
提出日時 2022-03-25 22:02:37
言語 D
(dmd 2.109.1)
結果
RE  
実行時間 -
コード長 543 bytes
コンパイル時間 1,742 ms
コンパイル使用メモリ 181,112 KB
実行使用メモリ 13,088 KB
最終ジャッジ日時 2024-06-22 14:42:12
合計ジャッジ時間 3,758 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];
	bool f = (b[0] == b[1]);
	for(auto i = 1; i < b.length - 1; i++){
		auto d = b[i + 1] - b[i];
		if(f){
			if(d > 0){
				m = -1;
				break;
			}
		}else{
			if(d == 0){
				m = -1;
				break;
			}
			m = m.gcd(d);
		}
	}
	stderr.writeln(m);
	if(b[$ - 1] - b[0] <= m * (n - 1)){
		writeln("Yes");
	}else{
		writeln("No");
	}
}
0