結果

問題 No.48 ロボットの操縦
ユーザー syusyu
提出日時 2020-08-26 17:57:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,366 ms / 5,000 ms
コード長 1,408 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 77,204 KB
実行使用メモリ 41,656 KB
最終ジャッジ日時 2024-04-25 03:32:30
合計ジャッジ時間 7,849 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,200 KB
testcase_01 AC 134 ms
41,124 KB
testcase_02 AC 133 ms
41,220 KB
testcase_03 AC 1,366 ms
41,412 KB
testcase_04 AC 134 ms
41,088 KB
testcase_05 AC 134 ms
41,112 KB
testcase_06 AC 117 ms
39,692 KB
testcase_07 AC 137 ms
41,080 KB
testcase_08 AC 134 ms
41,052 KB
testcase_09 AC 137 ms
41,356 KB
testcase_10 AC 130 ms
41,256 KB
testcase_11 AC 134 ms
41,132 KB
testcase_12 AC 141 ms
41,224 KB
testcase_13 AC 133 ms
40,984 KB
testcase_14 AC 135 ms
41,656 KB
testcase_15 AC 137 ms
41,128 KB
testcase_16 AC 134 ms
41,176 KB
testcase_17 AC 131 ms
40,900 KB
testcase_18 AC 134 ms
41,116 KB
testcase_19 AC 129 ms
41,176 KB
testcase_20 AC 132 ms
41,040 KB
testcase_21 AC 133 ms
41,164 KB
testcase_22 AC 138 ms
41,248 KB
testcase_23 AC 134 ms
41,208 KB
testcase_24 AC 118 ms
40,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int step=sc.nextInt();
        
        int count=0;
        int abs_x=Math.abs(x);
        int abs_y=Math.abs(y);
        
        if(y>0){
            while(y>step){
                y-=step;
                count++;
            }
            count++;
            if(x!=0){
                count++;
                while(abs_x>step){
                    abs_x-=step;
                    count++;
                }
                count++;
            }else{
                ;
            }
        }else if(y==0){
            if(x!=0){
                count++;
                while(abs_x>step){
                    abs_x-=step;
                    count++;
                }
                count++;
            }else{
                ;
            }
        }else{
            if(x!=0){
                count++;
                while(abs_x>step){
                    abs_x-=step;
                    count++;
                }
                count++;
            }else{
                count++;
            }
            count++;
            while(abs_y>step){
                abs_y-=step;
                count++;
            }
            count++;
        }
        System.out.println(count);
        
    }
}
0