結果
| 問題 | No.2767 Add to Divide |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-01 10:29:56 |
| 言語 | Rust (1.92.0 + proconio + num) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 508 bytes |
| 記録 | |
| コンパイル時間 | 20,272 ms |
| コンパイル使用メモリ | 376,624 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 16:09:31 |
| 合計ジャッジ時間 | 21,481 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 4 |
コンパイルメッセージ
warning: variable `T` should have a snake case name --> src/main.rs:20:9 | 20 | input!(T: usize); | ^ help: convert the identifier to snake case: `t` | = note: `#[warn(non_snake_case)]` on by default warning: variable `A` should have a snake case name --> src/main.rs:22:10 | 22 | input!(A: usize, B: usize); | ^ help: convert the identifier to snake case: `a` warning: variable `B` should have a snake case name --> src/main.rs:22:20 | 22 | input!(A: usize, B: usize); | ^ help: convert the identifier to snake case: `b`
ソースコード
use proconio::input;
fn divisors(n: usize) -> Vec<usize> {
let mut ds = vec![];
let mut k = 1;
while k * k < n {
if n % k == 0 {
ds.push(k);
ds.push(n / k);
}
k += 1;
}
if k * k == n {
ds.push(k);
}
ds
}
fn main() {
input!(T: usize);
for _ in 0 .. T {
input!(A: usize, B: usize);
if let Some(ans) = divisors(B - A).into_iter().filter_map(|d| if B >= A * (d + 1) { Some((B - A * (d + 1)) / d) } else { None } ).min() {
println!("{ans}");
} else {
println!("-1");
}
}
}