結果

問題 No.1884 Sequence
ユーザー kenya_hobbkenya_hobb
提出日時 2022-03-26 20:07:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,782 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 108,160 KB
実行使用メモリ 50,688 KB
最終ジャッジ日時 2024-04-23 12:21:21
合計ジャッジ時間 9,263 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
19,456 KB
testcase_01 WA -
testcase_02 AC 27 ms
19,328 KB
testcase_03 AC 26 ms
19,328 KB
testcase_04 AC 27 ms
19,200 KB
testcase_05 AC 28 ms
19,328 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 27 ms
19,456 KB
testcase_09 AC 27 ms
19,328 KB
testcase_10 AC 201 ms
50,432 KB
testcase_11 AC 198 ms
50,432 KB
testcase_12 AC 89 ms
27,904 KB
testcase_13 AC 101 ms
33,536 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 123 ms
37,120 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 202 ms
50,304 KB
testcase_24 AC 200 ms
50,560 KB
testcase_25 AC 199 ms
49,280 KB
testcase_26 AC 204 ms
50,176 KB
testcase_27 AC 112 ms
34,048 KB
testcase_28 AC 112 ms
34,048 KB
testcase_29 AC 109 ms
33,792 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 114 ms
34,688 KB
testcase_36 AC 159 ms
44,288 KB
testcase_37 AC 179 ms
50,304 KB
testcase_38 AC 167 ms
47,360 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 179 ms
45,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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++;
            }


            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