結果

問題 No.48 ロボットの操縦
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-24 04:55:42
言語 Java19
(openjdk 21)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 1,128 bytes
コンパイル時間 2,717 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 56,776 KB
最終ジャッジ日時 2023-08-14 00:37:49
合計ジャッジ時間 6,333 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
55,624 KB
testcase_01 AC 104 ms
55,928 KB
testcase_02 AC 102 ms
56,024 KB
testcase_03 AC 105 ms
55,828 KB
testcase_04 AC 109 ms
56,776 KB
testcase_05 AC 102 ms
56,012 KB
testcase_06 AC 103 ms
55,796 KB
testcase_07 AC 101 ms
55,928 KB
testcase_08 AC 102 ms
55,992 KB
testcase_09 AC 105 ms
56,096 KB
testcase_10 AC 100 ms
55,560 KB
testcase_11 AC 102 ms
55,564 KB
testcase_12 AC 102 ms
55,708 KB
testcase_13 AC 104 ms
55,664 KB
testcase_14 AC 106 ms
55,964 KB
testcase_15 AC 103 ms
56,000 KB
testcase_16 AC 105 ms
55,640 KB
testcase_17 AC 102 ms
55,632 KB
testcase_18 AC 104 ms
55,648 KB
testcase_19 AC 105 ms
55,840 KB
testcase_20 AC 107 ms
55,864 KB
testcase_21 AC 106 ms
55,588 KB
testcase_22 AC 104 ms
55,716 KB
testcase_23 AC 103 ms
55,648 KB
testcase_24 AC 106 ms
56,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Exercises13{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();

    int y = sc.nextInt();

    int maxMove = sc.nextInt();

    int oderCount = 0;

    if (y >= 0){
      double count = Math.ceil((double)y / (double)maxMove);
      oderCount += (int)count;

      // 方向転換
      // oderCount += 1;

      if (x > 0){
        oderCount += 1;
        count = Math.ceil((double)x / (double)maxMove);
        oderCount += (int)count;
      }else if (x < 0){
        oderCount += 1;
        count = Math.ceil((double)x / (double)maxMove * -1);
        oderCount += (int)count;
      }
    }else{
      oderCount += 1;

      if (x > 0){
        double count = Math.ceil((double)x / (double)maxMove);
        oderCount += (int)count;
      }else{
        double count = Math.ceil((double)x / (double)maxMove * -1);
        oderCount += (int)count;
      }

      oderCount += 1;

      double count = Math.ceil((double)y / (double)maxMove * -1);
      oderCount += (int)count;

    }

    System.out.println(oderCount);
  }
}
0