結果

問題 No.48 ロボットの操縦
ユーザー jp_stejp_ste
提出日時 2016-05-14 15:07:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 54,092 KB
最終ジャッジ日時 2024-04-15 21:26:13
合計ジャッジ時間 5,549 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
41,248 KB
testcase_01 AC 95 ms
39,872 KB
testcase_02 WA -
testcase_03 AC 115 ms
41,244 KB
testcase_04 AC 113 ms
41,132 KB
testcase_05 AC 112 ms
41,344 KB
testcase_06 AC 114 ms
40,896 KB
testcase_07 AC 114 ms
40,880 KB
testcase_08 AC 113 ms
41,088 KB
testcase_09 AC 114 ms
40,980 KB
testcase_10 AC 114 ms
41,228 KB
testcase_11 AC 114 ms
41,416 KB
testcase_12 AC 102 ms
39,964 KB
testcase_13 AC 100 ms
39,964 KB
testcase_14 AC 101 ms
39,984 KB
testcase_15 AC 112 ms
41,112 KB
testcase_16 AC 112 ms
41,336 KB
testcase_17 AC 101 ms
40,192 KB
testcase_18 AC 107 ms
41,080 KB
testcase_19 AC 116 ms
41,344 KB
testcase_20 AC 115 ms
41,376 KB
testcase_21 AC 113 ms
40,996 KB
testcase_22 AC 108 ms
40,480 KB
testcase_23 AC 114 ms
41,184 KB
testcase_24 AC 111 ms
41,276 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++;
                    count += (x / l);
                    if(x%l > 0) count++;
                    count++;
                    count += (y / l);
                    if(y%l > 0) count++;
                }
            }
            System.out.println(count);
        }
    }
}
0