結果

問題 No.48 ロボットの操縦
ユーザー kenji_shioya
提出日時 2016-05-24 04:55:42
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 1,128 bytes
コンパイル時間 2,994 ms
コンパイル使用メモリ 77,128 KB
実行使用メモリ 41,656 KB
最終ジャッジ日時 2024-11-21 18:41:03
合計ジャッジ時間 6,801 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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