結果

問題 No.49 算数の宿題
ユーザー magurogumamaguroguma
提出日時 2017-08-09 23:37:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 363 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-08-24 17:37:50
合計ジャッジ時間 1,265 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,208 KB
testcase_01 AC 27 ms
9,240 KB
testcase_02 AC 27 ms
9,140 KB
testcase_03 AC 27 ms
9,260 KB
testcase_04 AC 27 ms
9,008 KB
testcase_05 AC 26 ms
9,200 KB
testcase_06 AC 26 ms
9,100 KB
testcase_07 AC 26 ms
9,012 KB
testcase_08 AC 26 ms
9,104 KB
testcase_09 AC 26 ms
9,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import re

S = input()
temp = re.split('[*+]', S)
terms = list(map(int, temp))
temp = re.split('[0-9]', S)
operators = list(filter(lambda c:c!='', temp))

# 計算する
answer = terms[0]
for i in range(1, len(terms)):
    term = terms[i]
    if operators[i-1] == '*':
        answer += term
    else:
        answer *= term
print(answer)
0