結果

問題 No.1884 Sequence
ユーザー bluemeganebluemegane
提出日時 2022-03-26 07:17:11
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,474 bytes
コンパイル時間 5,948 ms
コンパイル使用メモリ 104,832 KB
実行使用メモリ 49,280 KB
最終ジャッジ日時 2024-04-22 17:27:48
合計ジャッジ時間 7,979 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
17,920 KB
testcase_01 AC 27 ms
17,792 KB
testcase_02 AC 26 ms
17,664 KB
testcase_03 AC 25 ms
17,536 KB
testcase_04 RE -
testcase_05 AC 25 ms
17,664 KB
testcase_06 AC 25 ms
17,792 KB
testcase_07 AC 28 ms
17,792 KB
testcase_08 AC 26 ms
17,792 KB
testcase_09 WA -
testcase_10 AC 202 ms
48,768 KB
testcase_11 AC 206 ms
49,152 KB
testcase_12 AC 65 ms
25,344 KB
testcase_13 AC 75 ms
30,592 KB
testcase_14 AC 64 ms
25,344 KB
testcase_15 AC 145 ms
41,984 KB
testcase_16 AC 210 ms
49,024 KB
testcase_17 AC 105 ms
36,352 KB
testcase_18 AC 149 ms
41,344 KB
testcase_19 AC 114 ms
39,936 KB
testcase_20 AC 131 ms
40,960 KB
testcase_21 AC 106 ms
35,456 KB
testcase_22 AC 141 ms
41,088 KB
testcase_23 AC 208 ms
48,896 KB
testcase_24 AC 212 ms
49,024 KB
testcase_25 AC 203 ms
48,100 KB
testcase_26 AC 206 ms
48,896 KB
testcase_27 AC 80 ms
30,848 KB
testcase_28 RE -
testcase_29 AC 82 ms
31,104 KB
testcase_30 AC 85 ms
30,848 KB
testcase_31 AC 126 ms
40,704 KB
testcase_32 WA -
testcase_33 AC 172 ms
49,280 KB
testcase_34 AC 179 ms
48,896 KB
testcase_35 AC 90 ms
32,000 KB
testcase_36 AC 144 ms
42,624 KB
testcase_37 AC 168 ms
49,152 KB
testcase_38 AC 156 ms
45,952 KB
testcase_39 AC 89 ms
34,304 KB
testcase_40 WA -
testcase_41 AC 163 ms
44,940 KB
testcase_42 AC 161 ms
45,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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 == 0) { 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;
    }
}
0