結果

問題 No.49 算数の宿題
ユーザー yoza
提出日時 2014-11-22 13:26:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-12-23 01:42:55
合計ジャッジ時間 1,077 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

formula = list(input())

result = 0
pre_ope = False # True:+ False:*
pre_num = 0
f = lambda r, n, o: r * n if o else r + n

for c in formula:
    if c == '+':
        result = f(result, pre_num, pre_ope)
        pre_num = 0
        pre_ope = True
    elif c == '*':
        result = f(result, pre_num, pre_ope)
        pre_num = 0
        pre_ope = False
    else:
        pre_num *= 10
        pre_num += int(c)
else:
    result = f(result, pre_num, pre_ope)

print(result)
0