結果

問題 No.49 算数の宿題
ユーザー ntuda
提出日時 2023-12-27 23:50:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 53,816 KB
最終ジャッジ日時 2024-09-27 15:36:34
合計ジャッジ時間 1,216 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input() + "*"
val = 0
cal = 0
nextv = 0
for s in S:
    if s == "*":
        if cal == 0:
            val += nextv
        else:
            val *= nextv
        nextv = 0
        cal = 0
    elif s == "+":
        if cal == 0:
            val += nextv
        else:
            val *= nextv
        nextv = 0
        cal = 1
    else:
        nextv *= 10
        nextv += int(s)
print(val)
0