結果
| 問題 |
No.1988 Divisor Tiling
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-10 01:09:11 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,339 bytes |
| コンパイル時間 | 13,229 ms |
| コンパイル使用メモリ | 377,320 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-26 01:56:27 |
| 合計ジャッジ時間 | 18,096 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 18 |
コンパイルメッセージ
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`
ソースコード
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");
}
}