結果

問題 No.49 算数の宿題
ユーザー lllllll88938494lllllll88938494
提出日時 2022-01-23 09:54:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 491 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-08-24 17:51:05
合計ジャッジ時間 905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,816 KB
testcase_01 AC 16 ms
7,760 KB
testcase_02 AC 16 ms
7,736 KB
testcase_03 AC 15 ms
7,976 KB
testcase_04 RE -
testcase_05 AC 15 ms
7,788 KB
testcase_06 AC 16 ms
7,876 KB
testcase_07 AC 16 ms
7,920 KB
testcase_08 AC 16 ms
7,980 KB
testcase_09 AC 16 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
ind=0
t=''
ans=0

for i in range(len(s)):
    if ans == 0:
        if s[i] == '+' or s[i] == '*':
            ans = int(s[:i])
            ind=i+1
            t=s[i]

    elif s[i] == '+' or s[i] == '*':
        if t == '+':
            ans *= int(s[ind:i])
            ind=i+1
            t = s[i] 
        elif t == '*':
            ans += int(s[ind:i])
            ind=i+1
            t = s[i]

if t == '+':
    ans *= int(s[ind:]) 
else:
    ans += int(s[ind:])
    
print(ans)
0