結果

問題 No.49 算数の宿題
ユーザー netyo715netyo715
提出日時 2021-07-15 14:42:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,520 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-08-24 17:50:21
合計ジャッジ時間 901 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,844 KB
testcase_01 AC 15 ms
7,832 KB
testcase_02 AC 15 ms
7,740 KB
testcase_03 AC 15 ms
7,760 KB
testcase_04 AC 14 ms
7,796 KB
testcase_05 AC 15 ms
7,836 KB
testcase_06 AC 15 ms
7,848 KB
testcase_07 AC 15 ms
7,896 KB
testcase_08 AC 14 ms
7,796 KB
testcase_09 AC 14 ms
7,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
x = []
l = 0
r = 0
while r < len(S):
    if S[r] in ["+", "*"]:
        x.append(S[l:r])
        x.append(S[r])
        l = r+1
        r = l
    r += 1
x.append(S[l:])
ans = int(x[0])
for i in range(2, len(x), 2):
    if x[i-1] == "+":
        ans *= int(x[i])
    else:
        ans += int(x[i])
print(ans)
0