結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー O2MTO2MT
提出日時 2021-11-07 01:28:02
言語 C#
(.NET 8.0.203)
結果
RE  
実行時間 -
コード長 1,303 bytes
コンパイル時間 10,541 ms
コンパイル使用メモリ 169,688 KB
実行使用メモリ 222,136 KB
最終ジャッジ日時 2024-04-25 14:06:54
合計ジャッジ時間 31,631 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,853 ms
66,932 KB
testcase_01 AC 62 ms
30,592 KB
testcase_02 RE -
testcase_03 AC 78 ms
35,576 KB
testcase_04 AC 81 ms
35,824 KB
testcase_05 AC 79 ms
35,696 KB
testcase_06 AC 77 ms
35,444 KB
testcase_07 AC 81 ms
36,072 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 61 ms
30,572 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 1,677 ms
65,804 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Linq;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToArray();
            var MAX_A = A.Max();
            var K = new int[N];
            for (int i = 0; i < N; i++)
            {
                K[i] = 1;
            }
            var divs = new int[MAX_A + 1];
            for (int i = 0; i <= MAX_A; i++)
            {
                divs[i] = 0;
            }
            foreach (var num in A)
            {
                for (int i = 1; i <= Math.Sqrt(num); i++)
                {
                    if (num % i == 0)
                    {
                        divs[i]++;
                        divs[num / i]++;
                    }
                }
            }
            for (int i = 0; i <= MAX_A; i++)
            {

                if (divs[i] > 0)
                {
                    K[N - divs[i]] = Math.Max(K[N - divs[i]], i);
                }
            }
            var now = 1;
            for (int i = 0; i < N; i++)
            {
                now = Math.Max(now, K[i]);
                Console.WriteLine(now);
            }
        }
    }
}
0