結果

問題 No.49 算数の宿題
コンテスト
ユーザー yansi819
提出日時 2024-05-26 12:51:31
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 78 ms
コンパイル使用メモリ 65,060 KB
実行使用メモリ 53,872 KB
最終ジャッジ日時 2026-10-16 00:58:22
合計ジャッジ時間 2,155 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def myeval(S):
    op = ""
    num = ""
    res = 0
    for c in S:
        if c != "+" and c != "*":
            num += c
        else:
            if op == "":
                res = int(num)
            else:
                if op == "+":
                    res += int(num)
                else:
                    res *= int(num)
            num = ""
            op = c
    if op == "+":
        res += int(num)
    else:
        res *= int(num)
    return res

S = input().rstrip()
S = S.replace("*", "%")
S = S.replace("+", "*")
S = S.replace("%", "+")
print(myeval(S))
0