結果

問題 No.49 算数の宿題
コンテスト
ユーザー lam6er
提出日時 2025-03-20 20:15:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 564 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 240 ms
コンパイル使用メモリ 95,856 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2026-07-07 08:35:34
合計ジャッジ時間 2,154 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input().strip()

tokens = []
temp_num = ''

# Tokenize the input string
for c in S:
    if c.isdigit():
        temp_num += c
    else:
        tokens.append(int(temp_num))
        temp_num = ''
        tokens.append(c)
tokens.append(int(temp_num))  # Add the last number

current = tokens[0]

# Process each operator and number pair
for i in range(1, len(tokens), 2):
    operator = tokens[i]
    num = tokens[i + 1]
    if operator == '*':
        current += num
    else:  # operator is '+', which means multiplication
        current *= num

print(current)
0