結果

問題 No.48 ロボットの操縦
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-07 15:45:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 77,616 KB
実行使用メモリ 54,312 KB
最終ジャッジ日時 2024-05-01 13:35:12
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
53,896 KB
testcase_01 AC 122 ms
54,176 KB
testcase_02 AC 105 ms
52,964 KB
testcase_03 AC 104 ms
54,156 KB
testcase_04 AC 104 ms
52,760 KB
testcase_05 AC 115 ms
52,984 KB
testcase_06 AC 112 ms
53,936 KB
testcase_07 AC 112 ms
53,856 KB
testcase_08 AC 108 ms
53,868 KB
testcase_09 AC 114 ms
53,868 KB
testcase_10 AC 103 ms
52,732 KB
testcase_11 AC 104 ms
52,720 KB
testcase_12 AC 116 ms
53,904 KB
testcase_13 AC 107 ms
52,900 KB
testcase_14 AC 117 ms
54,312 KB
testcase_15 AC 108 ms
53,480 KB
testcase_16 AC 108 ms
52,804 KB
testcase_17 AC 100 ms
52,680 KB
testcase_18 AC 114 ms
54,084 KB
testcase_19 AC 115 ms
53,832 KB
testcase_20 AC 110 ms
53,228 KB
testcase_21 AC 116 ms
54,120 KB
testcase_22 AC 107 ms
52,748 KB
testcase_23 AC 120 ms
54,004 KB
testcase_24 AC 117 ms
54,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int x = koko.nextInt();
        int y = koko.nextInt();
        int l = koko.nextInt();
        int dx = Math.abs(x);
        int dy = Math.abs(y);
        int mx = dx%l;
        int my = dy%l;
        int nx, ny;
        if(mx!=0){
            nx = 1+((dx-mx)/l);
        }else{
            nx =dx/l;
        }
        if(my!=0){
            ny = 1+((dy-my)/l);
        }else{
            ny =dy/l;
        }
        if(x==0&&y==0){
            System.out.println(0);
        }else if(x==0&&y>0){
            System.out.println(ny);
        }else if(x!=0&&y==0){
            System.out.println(nx+1);
        }else if(x!=0&&y>0){
            System.out.println(nx+ny+1);
        }else{
            System.out.println(nx+ny+2);
        }
        }
    }
0