結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー face4
提出日時 2018-04-16 21:17:50
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 744 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,550 ms
コンパイル使用メモリ 81,992 KB
実行使用メモリ 44,864 KB
最終ジャッジ日時 2026-03-14 09:32:35
合計ジャッジ時間 3,281 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        int y = Integer.parseInt(br.readLine());
        int l = Integer.parseInt(br.readLine());

        long res = 0;
        if(y > 0){
            if(x != 0) res++;
        }else if (y < 0){
            res += 2;
        }else if(y == 0){
            if(x != 0) res++;
        }

        res += Math.abs(x) / l + ((x%l == 0) ? 0 : 1);
        res += Math.abs(y) / l + ((y%l == 0) ? 0 : 1);
        
        System.out.println(res);
    }
}
0