結果

問題 No.48 ロボットの操縦
ユーザー ontama_12ontama_12
提出日時 2016-09-28 10:48:14
言語 JavaScript
(node v21.7.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,874 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 41,448 KB
最終ジャッジ日時 2024-04-21 01:32:02
合計ジャッジ時間 2,421 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
39,296 KB
testcase_01 AC 68 ms
38,912 KB
testcase_02 AC 64 ms
39,168 KB
testcase_03 AC 62 ms
38,912 KB
testcase_04 AC 62 ms
39,040 KB
testcase_05 AC 62 ms
38,912 KB
testcase_06 AC 61 ms
39,040 KB
testcase_07 AC 64 ms
39,296 KB
testcase_08 AC 67 ms
39,168 KB
testcase_09 AC 63 ms
39,168 KB
testcase_10 AC 61 ms
39,168 KB
testcase_11 AC 61 ms
39,296 KB
testcase_12 AC 62 ms
39,296 KB
testcase_13 AC 62 ms
39,296 KB
testcase_14 AC 64 ms
39,168 KB
testcase_15 AC 61 ms
39,040 KB
testcase_16 AC 62 ms
39,296 KB
testcase_17 AC 62 ms
39,296 KB
testcase_18 AC 60 ms
39,040 KB
testcase_19 AC 62 ms
38,912 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_move != 0) {
        if (north < 0) { //南に移動するときは東方向に移動してから南に移動することで最短になる
            robot_order++
        }
        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++
        }
    }

    //東方向へ移動
    if (east_move != 0) {
        robot_order++    //東西方向へ90度回転
        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