結果

問題 No.49 算数の宿題
ユーザー gorugo30gorugo30
提出日時 2021-02-26 13:24:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 71,396 KB
最終ジャッジ日時 2023-08-24 17:49:36
合計ジャッジ時間 1,653 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,184 KB
testcase_01 AC 77 ms
71,160 KB
testcase_02 AC 69 ms
71,160 KB
testcase_03 AC 71 ms
71,304 KB
testcase_04 AC 70 ms
71,172 KB
testcase_05 AC 70 ms
71,132 KB
testcase_06 AC 71 ms
71,156 KB
testcase_07 AC 72 ms
71,256 KB
testcase_08 AC 71 ms
71,252 KB
testcase_09 AC 70 ms
71,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
S = S.replace("*", "-")
S = S.replace("+", "*")
S = S.replace("-", "+")
while S.count("*") + S.count("+") > 0:
    if S.count("*") + S.count("+") == 1:
        print(eval(S))
        exit()
    i = 1000
    if "*" in S:
        i = min(i, S.index("*"))
    if "+" in S:
        i = min(i, S.index("+"))
    j = 1000
    if "*" in S[i + 1:]:
        j = min(j, S[i + 1:].index("*"))
    if "+" in S[i + 1:]:
        j = min(j, S[i + 1:].index("+"))
    j += i + 1
    S = str(eval(S[:j])) + S[j:]
0