結果

問題 No.48 ロボットの操縦
ユーザー ontama_12ontama_12
提出日時 2016-09-28 10:43:44
言語 JavaScript
(node v21.7.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,816 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 44,288 KB
最終ジャッジ日時 2023-08-03 01:47:57
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,192 KB
testcase_01 AC 88 ms
42,168 KB
testcase_02 AC 78 ms
42,340 KB
testcase_03 AC 78 ms
42,620 KB
testcase_04 AC 79 ms
42,280 KB
testcase_05 AC 78 ms
42,168 KB
testcase_06 AC 78 ms
42,304 KB
testcase_07 AC 78 ms
42,344 KB
testcase_08 AC 79 ms
42,164 KB
testcase_09 AC 81 ms
42,192 KB
testcase_10 AC 80 ms
42,132 KB
testcase_11 AC 80 ms
42,448 KB
testcase_12 AC 79 ms
42,284 KB
testcase_13 AC 78 ms
42,340 KB
testcase_14 AC 78 ms
42,160 KB
testcase_15 AC 79 ms
42,432 KB
testcase_16 AC 79 ms
42,188 KB
testcase_17 AC 77 ms
42,192 KB
testcase_18 AC 79 ms
42,164 KB
testcase_19 AC 79 ms
42,288 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