結果

問題 No.48 ロボットの操縦
ユーザー takutakutakutaku
提出日時 2020-10-06 16:28:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 1,059 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 72,608 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-09-27 07:59:31
合計ジャッジ時間 5,990 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,744 KB
testcase_01 AC 114 ms
55,744 KB
testcase_02 AC 115 ms
55,744 KB
testcase_03 AC 115 ms
55,672 KB
testcase_04 AC 114 ms
55,864 KB
testcase_05 AC 116 ms
55,868 KB
testcase_06 AC 117 ms
55,832 KB
testcase_07 AC 115 ms
55,760 KB
testcase_08 AC 117 ms
56,148 KB
testcase_09 AC 116 ms
56,012 KB
testcase_10 AC 116 ms
55,884 KB
testcase_11 AC 116 ms
56,112 KB
testcase_12 AC 118 ms
55,872 KB
testcase_13 AC 116 ms
55,748 KB
testcase_14 AC 115 ms
55,468 KB
testcase_15 AC 118 ms
55,816 KB
testcase_16 AC 115 ms
56,024 KB
testcase_17 AC 116 ms
56,352 KB
testcase_18 AC 114 ms
55,508 KB
testcase_19 AC 115 ms
55,928 KB
testcase_20 AC 118 ms
55,948 KB
testcase_21 AC 116 ms
55,792 KB
testcase_22 AC 115 ms
55,940 KB
testcase_23 AC 115 ms
55,700 KB
testcase_24 AC 124 ms
56,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        long x = Integer.parseInt(sc.nextLine());
        long y = Integer.parseInt(sc.nextLine());
        long l = Integer.parseInt(sc.nextLine());
        
        long count = 0;
        long dis = 0;
        // 向きの変更回数
        
        if(y >= 0 && x != 0 ) {
            count++;
        }else if(y < 0) {
            count += 2;
        }
        
         if(y < 0) {
            y = -y;
        }
        
        if(y % l != 0) {
            dis = y / l + 1;
            count += dis;
        }else {
            dis = y / l;
            count += dis;
            
        }
        
        if(x < 0) {
            x = -x;
        }
        
        if(x % l != 0) {
            dis = x / l + 1;
           count += dis;
        }else {
            dis = x / l;
            count += dis;
        }
        
        System.out.println(count);
    }
}
0