結果

問題 No.1083 余りの余り
ユーザー Yusei Kato
提出日時 2020-06-22 21:15:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 3,000 ms
コード長 1,500 bytes
コンパイル時間 2,879 ms
コンパイル使用メモリ 114,616 KB
実行使用メモリ 27,160 KB
最終ジャッジ日時 2024-07-03 18:52:39
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

namespace Problem1083
{
    class Program
    {
        static void Main(string[] args)
        {
            var buff = GetLongArray();
            long K = buff[1];
            var A = GetLongList();

            Console.WriteLine(Solver(K, A));

        }

        static long Solver (long k, List<long> list)
        {
            if (list.FindIndex(x => x <= k) == -1)
            {
                return k;
            }
            else
            {
                long temp = 0;
                long max = 0;
                for(int i = 0; i < list.Count; i++)
                {
                    if(list[i] <= k)
                    {
                        temp = Solver(k % list[i], list);
                        max = max < temp ? temp : max;
                    }
                }
                return max;
            }
        }

        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static List<long> GetLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}
0