結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
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 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 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 AC 6 ms
5,376 KB
testcase_31 AC 9 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `j`
  --> src/main.rs:24:21
   |
24 |                 for j in 0..factors[i] {
   |                     ^ help: if this is intentional, prefix it with an underscore: `_j`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `j`
  --> src/main.rs:31:21
   |
31 |                 for j in 0..factors[i] {
   |                     ^ help: if this is intentional, prefix it with an underscore: `_j`

ソースコード

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