結果

問題 No.48 ロボットの操縦
ユーザー jp_stejp_ste
提出日時 2016-05-14 15:12:52
言語 Java19
(openjdk 21)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 1,248 bytes
コンパイル時間 2,949 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 56,116 KB
最終ジャッジ日時 2023-08-14 00:35:14
合計ジャッジ時間 5,542 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,872 KB
testcase_01 AC 102 ms
55,776 KB
testcase_02 AC 105 ms
55,840 KB
testcase_03 AC 100 ms
55,308 KB
testcase_04 AC 100 ms
55,692 KB
testcase_05 AC 102 ms
56,116 KB
testcase_06 AC 103 ms
53,816 KB
testcase_07 AC 105 ms
55,632 KB
testcase_08 AC 106 ms
56,064 KB
testcase_09 AC 101 ms
55,756 KB
testcase_10 AC 100 ms
56,096 KB
testcase_11 AC 100 ms
55,964 KB
testcase_12 AC 97 ms
55,472 KB
testcase_13 AC 97 ms
56,016 KB
testcase_14 AC 99 ms
53,848 KB
testcase_15 AC 99 ms
55,284 KB
testcase_16 AC 102 ms
55,524 KB
testcase_17 AC 100 ms
55,800 KB
testcase_18 AC 102 ms
54,120 KB
testcase_19 AC 101 ms
55,728 KB
testcase_20 AC 99 ms
55,904 KB
testcase_21 AC 101 ms
55,632 KB
testcase_22 AC 98 ms
55,964 KB
testcase_23 AC 100 ms
56,048 KB
testcase_24 AC 101 ms
55,532 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