結果
問題 |
No.2767 Add to Divide
|
ユーザー |
|
提出日時 | 2024-05-31 21:57:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 17,282 ms |
コンパイル使用メモリ | 384,232 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2024-12-20 23:19:25 |
合計ジャッジ時間 | 27,268 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 TLE * 3 |
コンパイルメッセージ
warning: unused import: `std::cmp::max` --> src/main.rs:1:5 | 1 | use std::cmp::max; | ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: variable `INPUT` should have a snake case name --> src/main.rs:6:13 | 6 | let mut INPUT = io::BufReader::new(io::stdin().lock()).lines().map(Result::unwrap); | ^^^^^ help: convert the identifier to snake case: `input` | = note: `#[warn(non_snake_case)]` on by default warning: variable `OUTPUT` should have a snake case name --> src/main.rs:7:13 | 7 | let mut OUTPUT = io::BufWriter::new(io::stdout().lock()); | ^^^^^^ help: convert the identifier to snake case: `output`
ソースコード
use std::cmp::max; use std::io; use std::io::{Write, BufRead}; pub fn main(){ let mut INPUT = io::BufReader::new(io::stdin().lock()).lines().map(Result::unwrap); let mut OUTPUT = io::BufWriter::new(io::stdout().lock()); let test_cases:u32 = INPUT.next().unwrap().parse().unwrap(); for _ in 0..test_cases{ let inp = INPUT.next().unwrap(); let mut inpit = inp.split_ascii_whitespace(); let a:u32 = inpit.next().unwrap().parse().unwrap(); let b:u32 = inpit.next().unwrap().parse().unwrap(); let mut x = None; if a == b{x = Some(0);} for k in 2..=b/a { if (b-k*a) % (k-1) == 0{ x = Some((b-k*a) / (k-1)) } } match x { None => writeln!(OUTPUT, "-1").unwrap(), Some(x) => writeln!(OUTPUT, "{}", x).unwrap() } } }