結果

問題 No.48 ロボットの操縦
ユーザー butchi_ybutchi_y
提出日時 2014-10-23 23:05:41
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 34 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 39,552 KB
最終ジャッジ日時 2024-04-21 01:12:15
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

function Main(input) {
    var tmp = input.split("\n");
    var x = parseInt(tmp[0], 10);
    var y = parseInt(tmp[1], 10);
    var l = parseInt(tmp[2], 10);

    ans = minStep(x, y, l);
    console.log('%d', ans);

    function minStep(x, y, l) { 
        var absX = Math.abs(x);
        var absY = Math.abs(y);
        if(x === 0 && y === 0) {
            return 4;
        } else if(y === 0) {
            return minLineStep(l, absX);
        } else if(x === 0) {
            return minLineStep(l, absY);
        } else {
            return minLineStep(l, absX) + minLineStep(l, absY) + 1;
        }
    }

    function minLineStep(l, x) {
        return Math.floor((x + l - 1)/l);
    }
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0