結果

問題 No.49 算数の宿題
ユーザー tnoda_tnoda_
提出日時 2015-08-03 15:01:48
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 294 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 6,628 KB
実行使用メモリ 6,092 KB
最終ジャッジ日時 2023-08-24 17:26:34
合計ジャッジ時間 725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,940 KB
testcase_01 AC 10 ms
5,860 KB
testcase_02 AC 12 ms
6,092 KB
testcase_03 AC 11 ms
5,980 KB
testcase_04 AC 11 ms
5,932 KB
testcase_05 AC 11 ms
6,040 KB
testcase_06 AC 10 ms
5,980 KB
testcase_07 AC 11 ms
5,908 KB
testcase_08 AC 11 ms
5,940 KB
testcase_09 AC 10 ms
5,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import re

S = re.findall(r'\+|\*|\d+', raw_input().strip())
L = len(S)
acc = int(S[0])
i = 1
while i < L:
    if S[i] == '*':
        acc = acc + int(S[i+1])
        i += 2
    elif S[i] == '+':
        acc = acc * int(S[i+1])
        i += 2
    else:
        raise 'Invalid input'
print(acc)
0