結果
問題 | No.1988 Divisor Tiling |
ユーザー |
|
提出日時 | 2022-09-04 17:01:00 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,246 bytes |
コンパイル時間 | 932 ms |
コンパイル使用メモリ | 114,212 KB |
実行使用メモリ | 20,136 KB |
最終ジャッジ日時 | 2024-11-18 23:00:34 |
合計ジャッジ時間 | 3,773 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;}}