結果

問題 No.49 算数の宿題
ユーザー dangodango
提出日時 2023-06-15 16:13:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 322 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 79,964 KB
最終ジャッジ日時 2023-09-05 20:19:51
合計ジャッジ時間 2,836 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
79,964 KB
testcase_01 AC 152 ms
79,844 KB
testcase_02 AC 150 ms
79,784 KB
testcase_03 AC 149 ms
79,832 KB
testcase_04 AC 148 ms
79,800 KB
testcase_05 AC 149 ms
79,840 KB
testcase_06 AC 147 ms
79,928 KB
testcase_07 AC 151 ms
79,952 KB
testcase_08 AC 147 ms
79,788 KB
testcase_09 AC 149 ms
79,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
def calculate(S):
    S = re.findall(r'\d+|\D', S)
    result = int(S[0])
    for i in range(1, len(S), 2):
        if S[i] == '+':
            result += int(S[i+1])
        elif S[i] == '*':
            result *= int(S[i+1])
    return result
S = input().translate(str.maketrans('+*', '*+'))
print(calculate(S))
0