結果
問題 |
No.1884 Sequence
|
ユーザー |
![]() |
提出日時 | 2022-03-26 07:18:55 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,473 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 105,216 KB |
実行使用メモリ | 49,152 KB |
最終ジャッジ日時 | 2024-10-14 16:42:39 |
合計ジャッジ時間 | 9,682 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = new List<long>(); var z = 0; for (int i = 0; i < n; i++) { var t = long.Parse(line[i]); if (t == 0) z++; else a.Add(t); } getAns(n, z, a); } static bool checkD0(List<long> a) { var pre = a[0]; foreach (var x in a) if (x != pre) return false; return true; } static void getAns(int n, int z, List<long> a) { var acount = a.Count; if (acount <=2) { Console.WriteLine("Yes");return; } a.Sort(); var dlist = new List<long>(); var g = a[1] - a[0]; dlist.Add(g); for (int i = 2; i < acount; i++) { g = Gcd(g, a[i] - a[i - 1]); dlist.Add(a[i] - a[i - 1]); if (g == 0) break; } if (g == 0) { Console.WriteLine(checkD0(a) ? "Yes" : "No"); return; } var ans = 0L; foreach (var x in dlist) ans += x / g - 1; Console.WriteLine(z >= ans ? "Yes" : "No"); } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var w = a % b; a = b; b = w; } return a; } }