結果

問題 No.48 ロボットの操縦
ユーザー iwot
提出日時 2019-04-26 17:52:13
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 13,325 ms
コンパイル使用メモリ 403,916 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 17:28:56
合計ジャッジ時間 13,197 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let x: i32 = read();
    let y: i32 = read();
    let l: i32 = read();

    let add_step = |a: i32| {
        if a != 0 {
            ((a as f32 / l as f32).ceil() as i32).abs()
        } else {
            0
        }
    };

    let mut step = 0;
    if y < 0 {
        step += 2;
    }
    step += add_step(y);
    if x != 0 {
        step += 1;
    }
    step += add_step(x);
    println!("{}", step);
}
0