結果

問題 No.423 ハムスター語初級(数詞)
ユーザー ontama_12ontama_12
提出日時 2016-09-27 18:51:30
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-21 01:31:27
合計ジャッジ時間 1,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
38,528 KB
testcase_01 AC 58 ms
38,656 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//入力文字読み取り
var inputall = require('fs').readFileSync('/dev/stdin', 'utf8');

    while (inputall.indexOf("hamu", 0) != -1 && inputall.indexOf("ham", 0) != -1) {
        inputall = inputall.replace("hamu", 1);
        inputall = inputall.replace("ham", 0);
    }

    //数値化
  var  inputnumber = Number(inputall);

    //2進数を10進数へ変換
 var inputnumber_ten = parseInt(inputnumber, 2);

    //10進数を2倍
 var inputnumber_ten = inputnumber_ten * 2;

    //10進数を2進数へ
 var inputstr_binary = inputnumber_ten.toString(2)

    //ハム語へ変換
 while (inputstr_binary.indexOf("1", 0) != -1) {
     inputstr_binary = inputstr_binary.replace("1", "hamu");
    }
 while (inputstr_binary.indexOf("0", 0) != -1) {
     inputstr_binary = inputstr_binary.replace(0, "ham");
    }
 console.log(inputstr_binary)
0