結果

問題 No.48 ロボットの操縦
ユーザー takutakutakutaku
提出日時 2020-10-06 16:17:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 56,376 KB
最終ジャッジ日時 2023-09-27 07:59:11
合計ジャッジ時間 5,570 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
56,376 KB
testcase_01 AC 105 ms
55,860 KB
testcase_02 AC 110 ms
55,836 KB
testcase_03 AC 110 ms
55,824 KB
testcase_04 AC 106 ms
55,768 KB
testcase_05 AC 106 ms
55,812 KB
testcase_06 WA -
testcase_07 AC 110 ms
55,696 KB
testcase_08 AC 109 ms
55,852 KB
testcase_09 AC 107 ms
55,764 KB
testcase_10 AC 108 ms
55,736 KB
testcase_11 AC 106 ms
55,864 KB
testcase_12 AC 101 ms
56,104 KB
testcase_13 AC 108 ms
55,808 KB
testcase_14 AC 105 ms
56,240 KB
testcase_15 AC 107 ms
55,704 KB
testcase_16 AC 106 ms
55,676 KB
testcase_17 AC 110 ms
55,736 KB
testcase_18 AC 126 ms
55,516 KB
testcase_19 AC 104 ms
55,792 KB
testcase_20 AC 103 ms
55,744 KB
testcase_21 AC 106 ms
56,244 KB
testcase_22 AC 109 ms
56,064 KB
testcase_23 AC 108 ms
55,768 KB
testcase_24 AC 107 ms
55,708 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