結果

問題 No.49 算数の宿題
ユーザー c-yanc-yan
提出日時 2021-02-06 00:26:49
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 430 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2023-08-24 17:49:15
合計ジャッジ時間 886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,744 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 AC 16 ms
7,848 KB
testcase_04 AC 15 ms
7,740 KB
testcase_05 AC 15 ms
7,744 KB
testcase_06 AC 15 ms
7,744 KB
testcase_07 AC 15 ms
7,816 KB
testcase_08 AC 15 ms
7,812 KB
testcase_09 AC 15 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

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