結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー cra77756176
提出日時 2022-11-18 00:18:34
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 5,000 ms
+ 729µs
コード長 712 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,054 ms
コンパイル使用メモリ 186,664 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-08-31 00:24:16
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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