結果

問題 No.49 算数の宿題
ユーザー lam6er
提出日時 2025-03-20 18:36:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 53,448 KB
最終ジャッジ日時 2025-03-20 18:36:59
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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