結果

問題 No.48 ロボットの操縦
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-07 15:45:32
言語 Java19
(openjdk 21)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 74,140 KB
実行使用メモリ 56,536 KB
最終ジャッジ日時 2023-08-14 00:05:02
合計ジャッジ時間 5,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
55,972 KB
testcase_01 AC 106 ms
55,828 KB
testcase_02 AC 114 ms
55,792 KB
testcase_03 AC 113 ms
56,048 KB
testcase_04 AC 105 ms
54,608 KB
testcase_05 AC 107 ms
55,676 KB
testcase_06 AC 105 ms
55,868 KB
testcase_07 AC 108 ms
55,868 KB
testcase_08 AC 108 ms
55,668 KB
testcase_09 AC 111 ms
56,164 KB
testcase_10 AC 107 ms
55,868 KB
testcase_11 AC 106 ms
55,872 KB
testcase_12 AC 108 ms
55,744 KB
testcase_13 AC 112 ms
55,688 KB
testcase_14 AC 109 ms
56,200 KB
testcase_15 AC 111 ms
55,692 KB
testcase_16 AC 110 ms
56,216 KB
testcase_17 AC 107 ms
56,132 KB
testcase_18 AC 107 ms
56,536 KB
testcase_19 AC 106 ms
55,656 KB
testcase_20 AC 108 ms
56,096 KB
testcase_21 AC 106 ms
55,844 KB
testcase_22 AC 107 ms
55,988 KB
testcase_23 AC 106 ms
55,992 KB
testcase_24 AC 109 ms
55,776 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