結果
問題 | No.1884 Sequence |
ユーザー |
|
提出日時 | 2022-03-25 22:04:38 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 182,212 KB |
実行使用メモリ | 14,500 KB |
最終ジャッジ日時 | 2024-06-22 14:42:26 |
合計ジャッジ時間 | 5,086 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 WA * 1 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
import std; void main(){ auto n = readln.chomp.to!long; auto a = readln.chomp.split.to!(long[]); 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"); } }