結果

問題 No.48 ロボットの操縦
ユーザー face4face4
提出日時 2018-04-16 21:17:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 2,599 ms
コンパイル使用メモリ 72,388 KB
実行使用メモリ 49,628 KB
最終ジャッジ日時 2023-09-09 10:56:32
合計ジャッジ時間 4,918 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,304 KB
testcase_01 AC 41 ms
49,204 KB
testcase_02 AC 41 ms
49,184 KB
testcase_03 AC 41 ms
49,136 KB
testcase_04 AC 41 ms
49,244 KB
testcase_05 AC 41 ms
49,128 KB
testcase_06 AC 41 ms
49,200 KB
testcase_07 AC 40 ms
49,372 KB
testcase_08 AC 40 ms
49,296 KB
testcase_09 AC 41 ms
49,312 KB
testcase_10 AC 41 ms
49,136 KB
testcase_11 AC 40 ms
49,412 KB
testcase_12 AC 40 ms
49,252 KB
testcase_13 AC 41 ms
49,080 KB
testcase_14 AC 40 ms
49,084 KB
testcase_15 AC 40 ms
49,172 KB
testcase_16 AC 40 ms
49,220 KB
testcase_17 AC 41 ms
49,628 KB
testcase_18 AC 41 ms
49,412 KB
testcase_19 AC 42 ms
49,340 KB
testcase_20 AC 42 ms
49,452 KB
testcase_21 AC 41 ms
49,536 KB
testcase_22 AC 40 ms
49,264 KB
testcase_23 AC 41 ms
49,180 KB
testcase_24 AC 41 ms
49,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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