結果

問題 No.49 算数の宿題
ユーザー butchi_ybutchi_y
提出日時 2014-10-23 23:42:30
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 586 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 42,448 KB
最終ジャッジ日時 2023-08-24 17:22:56
合計ジャッジ時間 1,475 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
42,192 KB
testcase_01 AC 75 ms
42,280 KB
testcase_02 AC 78 ms
42,376 KB
testcase_03 AC 79 ms
42,208 KB
testcase_04 AC 79 ms
42,448 KB
testcase_05 AC 78 ms
42,344 KB
testcase_06 AC 79 ms
42,200 KB
testcase_07 AC 79 ms
42,252 KB
testcase_08 AC 83 ms
42,416 KB
testcase_09 AC 79 ms
42,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
    var inputArr = input.split('\n');
    var str = inputArr[0];
    var oArr = str.match(/[\*\+]/g);
    var nArr = str.match(/[0-9]+/g);

    var tmp = +nArr[0];

    var i;
    var len = oArr.length;
    for(i = 0; i < len; i++) {
        if(false) {
        } else if(oArr[i] === '*') {
            tmp += +nArr[i + 1];
        } else if(oArr[i] === '+') {
            tmp *= +nArr[i + 1];
        }
    }

    var ans = tmp;

    console.log(ans);
}

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