結果

問題 No.48 ロボットの操縦
ユーザー butchi_y
提出日時 2014-10-23 23:05:41
言語 JavaScript
(node v23.5.0)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 41,328 KB
最終ジャッジ日時 2024-10-12 23:32:09
合計ジャッジ時間 2,740 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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