結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー shigi
提出日時 2026-11-17 18:52:15
言語 Rust
(1.99.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
+ 4µs
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 558 ms
コンパイル使用メモリ 171,324 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-11-17 18:52:18
合計ジャッジ時間 2,747 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::process::exit;
use proconio::input;

fn check_end(x: i32, y: i32, c: i32) {
    if x == 0 && y == 0 {
        println!("{}", c);
        exit(0);
    }
}

fn main() {
    input!(mut x: i32);
    input!(mut y: i32);
    input!(l: i32);

    let mut c = 0;
    check_end(x, y, c);

    if y > 0 {
        c += (y + l - 1) / l;
        y = 0;
    }

    check_end(x, y, c);
    c += 1;

    if x < 0 {
        x = -x;
    }
    if x > 0 {
        c += (x + l - 1) / l;
        x = 0;
    }

    check_end(x, y, c);
    c += 1;

    if y < 0 {
        c += (-y + l - 1) / l;
    }

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