結果

問題 No.48 ロボットの操縦
ユーザー ontama_12ontama_12
提出日時 2016-09-28 10:43:44
言語 JavaScript
(node v21.7.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,816 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 38,784 KB
最終ジャッジ日時 2024-04-21 01:31:59
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
38,528 KB
testcase_01 AC 66 ms
38,400 KB
testcase_02 AC 58 ms
38,656 KB
testcase_03 AC 57 ms
38,656 KB
testcase_04 AC 55 ms
38,784 KB
testcase_05 AC 56 ms
38,400 KB
testcase_06 AC 55 ms
38,528 KB
testcase_07 AC 55 ms
38,528 KB
testcase_08 AC 60 ms
38,528 KB
testcase_09 AC 55 ms
38,528 KB
testcase_10 AC 56 ms
38,400 KB
testcase_11 AC 57 ms
38,656 KB
testcase_12 AC 55 ms
38,656 KB
testcase_13 AC 54 ms
38,784 KB
testcase_14 AC 59 ms
38,784 KB
testcase_15 AC 55 ms
38,528 KB
testcase_16 AC 55 ms
38,400 KB
testcase_17 AC 58 ms
38,528 KB
testcase_18 AC 59 ms
38,528 KB
testcase_19 AC 56 ms
38,528 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

    /////////////////////////////////No.48 ロボットの操縦
    //入力文字読み取り
   var inputall = require('fs').readFileSync('/dev/stdin', 'utf8');


    //すべて受け取り改行で区切って格納
    var inputline = inputall.split("\n");

    //東西方向への移動距離の絶対値(東西がどっちかは関係ない)
    var east = Number(inputline[0]);
   var  east_move =  Math.abs(east)

    //南北方向への移動距離の絶対値(南北がどっちかは関係ない)
    var north = Number(inputline[1]);
    var north_move = Math.abs(north)

    //ロボットが前進することができる最大の距離
    var robot_move = Number(inputline[2]);

    //ロボットへの命令量
    var robot_order = 0

    //南に移動するとき
    if (north <0) {
        robot_order ++
    }

    //北方向へ移動
    if (north_move != 0) {
        var north_division = Math.floor(north_move / robot_move);
        if (north_division == 0) { //何回の命令でたどり着けるか
            robot_order++
        } else {
            robot_order += north_division
        }
        if (north_move % robot_move != 0) { //余りが出ると命令量が1増える
            robot_order++
        }
    }

    //東西方向へ90度回転するかどうか
    if (east_move != 0) {
        robot_order++
    }

    //東方向へ移動
    if (east_move != 0) {
        var east_division = Math.floor(east_move / robot_move);
        if (east_division ==  0) {  //何回の命令でたどり着けるか
            robot_order++
        } else {
            robot_order += east_division
        }
        if (east_move % robot_move != 0) {//余りが出ると命令量が1増える
            robot_order++
        }
    }

    console.log(robot_order)
0