結果

問題 No.48 ロボットの操縦
ユーザー cra77756176cra77756176
提出日時 2022-11-18 00:18:34
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 18,705 ms
コンパイル使用メモリ 404,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 10:45:38
合計ジャッジ時間 12,365 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, BufRead};

fn main() {
    let input = io::stdin()
        .lock()
        .lines()
        .map(|n| n.unwrap().parse::<isize>().unwrap())
        .collect::<Vec<_>>();

    if let &[x, y, l] = &input[..] {
        let rotations = if y >= 0 {
            if x == 0 {
                0
            } else {
                1
            }
        } else {
            2
        };
        let x_moves = if x.abs() % l == 0 {
            x.abs() / l
        } else {
            x.abs() / l + 1
        };
        let y_moves = if y.abs() % l == 0 {
            y.abs() / l
        } else {
            y.abs() / l + 1
        };

        println!("{}", rotations + x_moves + y_moves);
    }
}
0