結果

問題 No.48 ロボットの操縦
ユーザー estece1
提出日時 2023-06-05 19:45:54
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 776 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 12,745 ms
コンパイル使用メモリ 401,012 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 06:19:51
合計ジャッジ時間 14,952 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

macro_rules! scan {
    ($buf:expr) => {{
        use std::io::{stdin, BufRead};
        use std::str::FromStr;

        $buf.clear();
        stdin().lock().read_line(&mut $buf).unwrap();
        FromStr::from_str($buf.trim()).unwrap()
    }};
}

fn main() {
    let mut b = String::new();

    let x: i32 = scan!(b);
    let y: i32 = scan!(b);
    let l: i32 = scan!(b);

    let mut c;
    if y < 0 {
        c = 2;
    } else if x == 0 {
        c = 0
    } else {
        c = 1;
    }

    let mut pos_x = x.abs();
    while 0 < pos_x {
        pos_x -= l;
        c += 1;
    }
    let mut pos_y = y.abs();
    while 0 < pos_y {
        pos_y -= l;
        c += 1;
    }

    println!("{c}");
}
0