結果

問題 No.48 ロボットの操縦
ユーザー jp_stejp_ste
提出日時 2016-05-14 15:12:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 1,248 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 77,740 KB
実行使用メモリ 54,316 KB
最終ジャッジ日時 2024-05-01 13:54:08
合計ジャッジ時間 5,828 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
53,440 KB
testcase_01 AC 92 ms
52,456 KB
testcase_02 AC 98 ms
52,592 KB
testcase_03 AC 110 ms
54,108 KB
testcase_04 AC 109 ms
54,216 KB
testcase_05 AC 92 ms
52,068 KB
testcase_06 AC 110 ms
53,928 KB
testcase_07 AC 111 ms
54,000 KB
testcase_08 AC 109 ms
53,828 KB
testcase_09 AC 109 ms
54,316 KB
testcase_10 AC 96 ms
52,876 KB
testcase_11 AC 110 ms
53,748 KB
testcase_12 AC 106 ms
53,628 KB
testcase_13 AC 107 ms
53,876 KB
testcase_14 AC 96 ms
52,612 KB
testcase_15 AC 111 ms
53,976 KB
testcase_16 AC 112 ms
54,080 KB
testcase_17 AC 111 ms
52,964 KB
testcase_18 AC 100 ms
52,644 KB
testcase_19 AC 110 ms
53,728 KB
testcase_20 AC 112 ms
53,852 KB
testcase_21 AC 114 ms
53,740 KB
testcase_22 AC 105 ms
53,312 KB
testcase_23 AC 107 ms
54,004 KB
testcase_24 AC 110 ms
54,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int x = Integer.parseInt(scan.next());
            int y = Integer.parseInt(scan.next());
            int l = Integer.parseInt(scan.next());
            
            int count = 0;
            if(y >= 0) {
                x = Math.abs(x);
                y = Math.abs(y);
                count += (y / l);
                if(y%l > 0) count++;
                if(x != 0) {
                    count++;
                    count += (x / l);
                    if(x%l > 0) count++;
                }
                
            } else if(y < 0) {
                x = Math.abs(x);
                y = Math.abs(y);
                if(x == 0) {
                    count+=2;
                    count += (y / l);
                    if(y%l > 0) count++;
                } else if(x > 0) { 
                    count++;
                    count += (x / l);
                    if(x%l > 0) count++;
                    count++;
                    count += (y / l);
                    if(y%l > 0) count++;
                }
            }
            System.out.println(count);
        }
    }
}
0