結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
39,040 KB
testcase_01 AC 67 ms
39,040 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 62 ms
39,040 KB
testcase_05 AC 62 ms
39,168 KB
testcase_06 WA -
testcase_07 AC 62 ms
39,168 KB
testcase_08 WA -
testcase_09 AC 67 ms
39,168 KB
testcase_10 WA -
testcase_11 AC 65 ms
38,912 KB
testcase_12 AC 63 ms
38,912 KB
testcase_13 AC 63 ms
38,912 KB
testcase_14 AC 62 ms
39,040 KB
testcase_15 AC 63 ms
39,296 KB
testcase_16 AC 63 ms
39,296 KB
testcase_17 AC 63 ms
39,168 KB
testcase_18 WA -
testcase_19 AC 63 ms
39,040 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 63 ms
38,912 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 (north_move != 0 && 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