結果

問題 No.1988 Divisor Tiling
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-04 17:01:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 2,385 ms
コンパイル使用メモリ 107,904 KB
実行使用メモリ 20,000 KB
最終ジャッジ日時 2024-04-29 17:20:18
合計ジャッジ時間 3,920 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
19,200 KB
testcase_01 AC 31 ms
19,200 KB
testcase_02 AC 31 ms
19,072 KB
testcase_03 AC 32 ms
19,200 KB
testcase_04 AC 31 ms
19,072 KB
testcase_05 AC 32 ms
19,072 KB
testcase_06 AC 31 ms
19,328 KB
testcase_07 AC 33 ms
19,072 KB
testcase_08 AC 33 ms
19,200 KB
testcase_09 AC 33 ms
19,328 KB
testcase_10 AC 32 ms
19,200 KB
testcase_11 AC 32 ms
19,200 KB
testcase_12 AC 32 ms
19,328 KB
testcase_13 AC 33 ms
19,200 KB
testcase_14 AC 32 ms
19,328 KB
testcase_15 AC 33 ms
19,328 KB
testcase_16 AC 32 ms
19,200 KB
testcase_17 AC 32 ms
19,328 KB
testcase_18 AC 34 ms
19,420 KB
testcase_19 AC 34 ms
19,544 KB
testcase_20 AC 34 ms
19,572 KB
testcase_21 AC 34 ms
19,668 KB
testcase_22 AC 35 ms
19,660 KB
testcase_23 AC 35 ms
19,920 KB
testcase_24 AC 35 ms
19,436 KB
testcase_25 AC 35 ms
19,676 KB
testcase_26 AC 36 ms
19,420 KB
testcase_27 AC 34 ms
19,664 KB
testcase_28 AC 35 ms
19,616 KB
testcase_29 AC 34 ms
19,660 KB
testcase_30 AC 35 ms
19,756 KB
testcase_31 AC 35 ms
20,000 KB
testcase_32 AC 33 ms
19,072 KB
testcase_33 AC 32 ms
19,200 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 static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, h) = (c[0], c[1]);
        var list = new List<int>();
        foreach (var pi in PDiv(n))
        {
            if (pi == n) break;
            list.AddRange(Enumerable.Repeat(pi, pi));
        }
        var w = n / h;
        var res = new int[h][];
        for (var i = 0; i < res.Length; ++i) res[i] = new int[w];
        for (var i = 0; i < list.Count; ++i)
        {
            if (w > h) res[i / w][i % w] = list[i];
            else res[i % h][i / h] = list[i];
        }
        WriteLine(string.Join("\n", res.Select(r => string.Join(" ", r))));
    }
    static List<int> PDiv(int n)
    {
        var list = new List<int>();
        var rev = new List<int>();
        for (var i = 1; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                list.Add(i);
                if (i * i < n) rev.Add(n / i);
            }
        }
        rev.Reverse();
        list.AddRange(rev);
        return list;
    }
}
0