結果

問題 No.48 ロボットの操縦
ユーザー ontama_12ontama_12
提出日時 2016-09-28 10:33:20
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 1,746 bytes
コンパイル時間 30 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 41,456 KB
最終ジャッジ日時 2024-04-21 01:31:56
合計ジャッジ時間 2,731 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
39,168 KB
testcase_01 AC 69 ms
39,168 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 70 ms
39,168 KB
testcase_05 AC 69 ms
39,424 KB
testcase_06 AC 72 ms
39,168 KB
testcase_07 AC 70 ms
39,168 KB
testcase_08 WA -
testcase_09 AC 68 ms
39,296 KB
testcase_10 WA -
testcase_11 AC 69 ms
39,424 KB
testcase_12 AC 68 ms
39,296 KB
testcase_13 AC 69 ms
39,296 KB
testcase_14 AC 71 ms
39,168 KB
testcase_15 AC 70 ms
41,456 KB
testcase_16 AC 70 ms
39,296 KB
testcase_17 AC 69 ms
39,424 KB
testcase_18 WA -
testcase_19 AC 68 ms
39,040 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 69 ms
39,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


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

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

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

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

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

    //北方向へ移動
    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