結果
| 問題 |
No.1884 Sequence
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2022-03-26 07:15:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,412 bytes |
| コンパイル時間 | 2,417 ms |
| コンパイル使用メモリ | 112,912 KB |
| 実行使用メモリ | 58,496 KB |
| 最終ジャッジ日時 | 2024-10-14 16:36:39 |
| 合計ジャッジ時間 | 10,607 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 WA * 3 RE * 4 |
コンパイルメッセージ
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)
{
a.Sort();
var acount = a.Count;
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;
}
}
bluemegane