結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,996 KB
testcase_01 AC 123 ms
55,724 KB
testcase_02 WA -
testcase_03 AC 122 ms
55,732 KB
testcase_04 AC 122 ms
55,688 KB
testcase_05 AC 122 ms
55,496 KB
testcase_06 AC 123 ms
55,596 KB
testcase_07 AC 122 ms
55,720 KB
testcase_08 AC 122 ms
55,568 KB
testcase_09 AC 123 ms
55,512 KB
testcase_10 AC 123 ms
55,676 KB
testcase_11 AC 121 ms
56,000 KB
testcase_12 AC 123 ms
55,712 KB
testcase_13 AC 122 ms
55,876 KB
testcase_14 AC 121 ms
56,280 KB
testcase_15 AC 121 ms
55,676 KB
testcase_16 AC 121 ms
55,496 KB
testcase_17 AC 121 ms
55,556 KB
testcase_18 AC 121 ms
56,292 KB
testcase_19 AC 122 ms
57,788 KB
testcase_20 AC 122 ms
55,952 KB
testcase_21 AC 121 ms
55,812 KB
testcase_22 AC 121 ms
56,104 KB
testcase_23 AC 120 ms
56,140 KB
testcase_24 AC 122 ms
55,984 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 && X != 0){
                count++;
            }else if(Y < 0 && X != 0){
                count += 2;
            }
        
            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