結果

問題 No.1988 Divisor Tiling
ユーザー phsplsphspls
提出日時 2022-09-10 00:51:21
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 14,034 ms
コンパイル使用メモリ 377,512 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 13:51:02
合計ジャッジ時間 16,647 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nh = String::new();
    std::io::stdin().read_line(&mut nh).ok();
    let nh: Vec<usize> = nh.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nh[0];
    let h = nh[1];

    let mut factors = vec![];
    for i in 1..n {
        if n % i == 0 {
            factors.push(i);
        }
    }
    if n / h <= 2 || h <= 2  {
        if n / h == 1 || h == 1 {
            println!("{}", factors.iter().flat_map(|&i| (0..i).map(|_| i.to_string()).collect::<Vec<String>>()).collect::<Vec<String>>().join(" "));
        } else {
            let val = factors.pop().unwrap();
            println!("{}", (0..val).map(|_| val.to_string()).collect::<Vec<String>>().join(" "));
            println!("{}", factors.iter().flat_map(|&i| (0..i).map(|_| i.to_string()).collect::<Vec<String>>()).collect::<Vec<String>>().join(" "));
        }
    } else {
        println!("-1");
    }
}
0