結果

問題 No.1988 Divisor Tiling
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-04 17:01:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 68,152 KB
実行使用メモリ 24,088 KB
最終ジャッジ日時 2023-08-12 02:42:30
合計ジャッジ時間 6,623 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,868 KB
testcase_01 AC 66 ms
21,908 KB
testcase_02 AC 66 ms
24,012 KB
testcase_03 AC 67 ms
21,880 KB
testcase_04 AC 67 ms
23,916 KB
testcase_05 AC 67 ms
21,928 KB
testcase_06 AC 66 ms
24,088 KB
testcase_07 AC 66 ms
21,856 KB
testcase_08 AC 66 ms
21,924 KB
testcase_09 AC 66 ms
21,932 KB
testcase_10 AC 67 ms
21,968 KB
testcase_11 AC 67 ms
22,028 KB
testcase_12 AC 68 ms
21,908 KB
testcase_13 AC 67 ms
21,924 KB
testcase_14 AC 67 ms
21,804 KB
testcase_15 AC 66 ms
21,912 KB
testcase_16 AC 67 ms
23,916 KB
testcase_17 AC 66 ms
21,860 KB
testcase_18 AC 69 ms
21,932 KB
testcase_19 AC 69 ms
21,912 KB
testcase_20 AC 69 ms
19,936 KB
testcase_21 AC 68 ms
21,960 KB
testcase_22 AC 69 ms
21,808 KB
testcase_23 AC 70 ms
23,876 KB
testcase_24 AC 70 ms
19,928 KB
testcase_25 AC 71 ms
23,900 KB
testcase_26 AC 70 ms
24,032 KB
testcase_27 AC 68 ms
21,872 KB
testcase_28 AC 68 ms
21,992 KB
testcase_29 AC 69 ms
22,032 KB
testcase_30 AC 69 ms
23,916 KB
testcase_31 AC 70 ms
21,928 KB
testcase_32 AC 66 ms
23,900 KB
testcase_33 AC 65 ms
19,820 KB
権限があれば一括ダウンロードができます

ソースコード

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