結果

問題 No.1884 Sequence
ユーザー kenya_hobbkenya_hobb
提出日時 2022-03-26 20:10:44
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,811 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 107,648 KB
実行使用メモリ 50,688 KB
最終ジャッジ日時 2024-04-23 12:24:04
合計ジャッジ時間 10,052 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
19,456 KB
testcase_01 AC 29 ms
19,328 KB
testcase_02 AC 30 ms
19,456 KB
testcase_03 AC 29 ms
19,456 KB
testcase_04 AC 30 ms
19,328 KB
testcase_05 AC 29 ms
19,328 KB
testcase_06 AC 30 ms
19,328 KB
testcase_07 AC 30 ms
19,200 KB
testcase_08 AC 31 ms
19,456 KB
testcase_09 WA -
testcase_10 AC 229 ms
50,432 KB
testcase_11 AC 227 ms
50,304 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 98 ms
28,160 KB
testcase_15 AC 172 ms
39,168 KB
testcase_16 AC 222 ms
50,304 KB
testcase_17 WA -
testcase_18 AC 174 ms
44,544 KB
testcase_19 AC 144 ms
37,632 KB
testcase_20 AC 158 ms
37,888 KB
testcase_21 AC 145 ms
36,096 KB
testcase_22 AC 165 ms
38,784 KB
testcase_23 AC 212 ms
50,304 KB
testcase_24 AC 218 ms
50,176 KB
testcase_25 AC 210 ms
49,280 KB
testcase_26 AC 223 ms
50,176 KB
testcase_27 AC 120 ms
33,920 KB
testcase_28 AC 118 ms
33,792 KB
testcase_29 AC 123 ms
33,792 KB
testcase_30 AC 124 ms
33,792 KB
testcase_31 AC 152 ms
37,504 KB
testcase_32 AC 220 ms
49,152 KB
testcase_33 AC 199 ms
50,688 KB
testcase_34 AC 198 ms
50,304 KB
testcase_35 AC 127 ms
34,816 KB
testcase_36 AC 179 ms
44,032 KB
testcase_37 AC 204 ms
50,176 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 199 ms
45,824 KB
testcase_42 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {
        //private static int[] A = new int[200005];//MargeSort用
        //private static int[] C = new int[200005];

        static void Main(string[] args)
        {
			long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray(); //SelectはLinq
            bool ok = true;

            Array.Sort(A);
            Array.Reverse(A);
            long kousa = A[0] - A[1];
            long need_zero = 0;


            for(int i = 1; i < N - 1; i++)
            { 
                if(A[i + 1] != 0 && A[i] != 0)
                    kousa = GCD(kousa, A[i] - A[i + 1]);
            }

            for (int i = 0; i < N - 1; i++)
            {
                if (A[i] - A[i + 1] != kousa && A[i] != 0 && A[i + 1] != 0)
                    need_zero += (A[i] - A[i + 1]) / kousa;
            }


            if (need_zero <= A.Count(x => x == 0))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }

        static long GCD(long a, long b)//公約数 再起関数にしてみるいつか
        {
            while (a > 0 && b > 0)
            {
                if (a > b)
                    a = a % b;
                else
                    b = b % a;
            }

            if (a == 0)
                return b;
            else
                return a;
        }

        static long LCD(long a, long b)
        {
            return a / GCD(a, b) * b;
        }


        //static void MargeSort(int l, int r)//A配列とC配列(ソート後)を用意する必要あり
        //{
        //    if (r - l == 1) return;

        //    int m = (l + r) / 2;
        //    MargeSort(l, m);
        //    MargeSort(m, r);

        //    int c1 = l, c2 = m, cnt = 0;
        //    while(c1 != m || c2 != r)
        //    {
        //        if(c1 == m)
        //        {
        //            C[cnt] = A[c2];
        //            c2++;
        //        }
        //        else if(c2 == r)
        //        {
        //            C[cnt] = A[c1];
        //            c1++;
        //        }
        //        else
        //        {
        //            if (A[c1] <= A[c2])
        //            {
        //                C[cnt] = A[c1];
        //                c1++;
        //            }
        //            else
        //            {
        //                C[cnt] = A[c2];
        //                c2++;
        //            }
        //        }

        //        cnt++;

        //    }

        //    for(int i = 0; i < cnt; i++)
        //    {
        //        A[l + i] = C[i];
        //    }

        //}

    }
}
0