結果

問題 No.49 算数の宿題
ユーザー lllllll88938494lllllll88938494
提出日時 2022-01-23 10:04:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 7,876 KB
最終ジャッジ日時 2023-08-24 17:51:00
合計ジャッジ時間 928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,876 KB
testcase_01 AC 16 ms
7,768 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 AC 16 ms
7,840 KB
testcase_04 AC 16 ms
7,792 KB
testcase_05 AC 16 ms
7,832 KB
testcase_06 AC 16 ms
7,780 KB
testcase_07 AC 15 ms
7,784 KB
testcase_08 AC 16 ms
7,832 KB
testcase_09 AC 17 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    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