結果

問題 No.48 ロボットの操縦
ユーザー SagTokiSagToki
提出日時 2018-05-14 11:10:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 3,112 ms
コンパイル使用メモリ 73,220 KB
実行使用メモリ 56,416 KB
最終ジャッジ日時 2023-09-10 19:44:58
合計ジャッジ時間 7,251 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,440 KB
testcase_01 AC 121 ms
55,448 KB
testcase_02 AC 121 ms
55,660 KB
testcase_03 AC 121 ms
55,976 KB
testcase_04 AC 120 ms
56,392 KB
testcase_05 AC 120 ms
55,940 KB
testcase_06 AC 120 ms
55,924 KB
testcase_07 AC 120 ms
55,612 KB
testcase_08 AC 121 ms
56,416 KB
testcase_09 AC 120 ms
55,632 KB
testcase_10 AC 121 ms
55,448 KB
testcase_11 AC 122 ms
56,180 KB
testcase_12 AC 120 ms
55,440 KB
testcase_13 AC 124 ms
55,904 KB
testcase_14 AC 120 ms
55,936 KB
testcase_15 AC 119 ms
55,872 KB
testcase_16 AC 120 ms
55,616 KB
testcase_17 AC 121 ms
55,392 KB
testcase_18 AC 120 ms
55,684 KB
testcase_19 AC 121 ms
56,136 KB
testcase_20 AC 122 ms
55,876 KB
testcase_21 AC 123 ms
55,652 KB
testcase_22 AC 122 ms
55,688 KB
testcase_23 AC 121 ms
55,804 KB
testcase_24 AC 122 ms
55,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class PilotingTheRobot {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
            double X = scanner.nextInt();
            double Y = scanner.nextInt();
            double L = scanner.nextInt();
            int count = 0; //命令回数
           
            if(L<1 || L>Math.pow(10,9)){
                System.out.println("Lは1≦L≦1000000000の範囲で入力してください");
                System.exit(0);
            }

            if(Y < 0){
                count += 2;
            }else if(X != 0){
                count ++;
            }
        
            if(X<0){
                X = X * -1;
            }
            count += Math.ceil(X/L);
            if(Y<0){
                Y = Y * -1;
            }
            count +=  Math.ceil(Y/L);
            
            System.out.println(count);          
        }catch(InputMismatchException e){
            System.out.println("数値を入力してください。");
        }catch(Exception E){
            System.out.println("予期せぬエラーです");
        }
    }  
}
0