結果

問題 No.49 算数の宿題
ユーザー c-yan
提出日時 2021-02-06 00:26:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 430 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-12-23 02:13:52
合計ジャッジ時間 1,024 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def tokenize(s):
    t = ''
    for c in s:
        if c not in '+*':
            t += c
        else:
            yield int(t)
            t = ''
            yield c
    yield int(t)


S = input()
s = []
for t in tokenize(S):
    s.append(t)
    if len(s) != 3:
        continue
    b = s.pop()
    op = s.pop()
    a = s.pop()
    if op == '+':
        s.append(a * b)
    elif op == '*':
        s.append(a + b)
print(s.pop())
0