結果

問題 No.48 ロボットの操縦
ユーザー SagTokiSagToki
提出日時 2018-05-14 11:09:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,147 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 72,224 KB
実行使用メモリ 57,704 KB
最終ジャッジ日時 2023-09-10 19:44:30
合計ジャッジ時間 8,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,848 KB
testcase_01 AC 127 ms
55,588 KB
testcase_02 AC 124 ms
55,644 KB
testcase_03 AC 124 ms
55,808 KB
testcase_04 AC 124 ms
55,532 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 124 ms
55,704 KB
testcase_08 AC 124 ms
55,852 KB
testcase_09 AC 122 ms
56,160 KB
testcase_10 AC 124 ms
55,416 KB
testcase_11 AC 128 ms
55,728 KB
testcase_12 AC 125 ms
55,748 KB
testcase_13 AC 126 ms
55,664 KB
testcase_14 AC 124 ms
55,616 KB
testcase_15 AC 128 ms
55,756 KB
testcase_16 AC 123 ms
55,636 KB
testcase_17 AC 124 ms
55,780 KB
testcase_18 AC 124 ms
55,804 KB
testcase_19 AC 125 ms
55,592 KB
testcase_20 AC 124 ms
55,964 KB
testcase_21 AC 124 ms
55,632 KB
testcase_22 AC 123 ms
55,752 KB
testcase_23 AC 123 ms
55,716 KB
testcase_24 AC 125 ms
55,484 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