結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー mlpj56d
提出日時 2017-06-28 04:31:20
言語 JavaScript
(node v23.5.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 39,168 KB
最終ジャッジ日時 2024-10-13 00:13:33
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
    var N = input;
    var binN = parseInt(N, 10).toString(2);
    var arr = binN.split("").map(Number);
    var pSum = 1;
    var count = 0;

    for (var i = 1; i < arr.length; i++) {
        pSum *= 2;
        count += 1;
    }

    if (N == pSum) {
        count += 0;
    } else if((N - pSum) % 2 == 0 || N - pSum == 1) {
        count += 1;
    } else {
        count += 2;
    }

    console.log(count);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0