結果

問題 No.49 算数の宿題
ユーザー DialBirdDialBird
提出日時 2017-03-13 19:59:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 529 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-08-24 17:36:27
合計ジャッジ時間 1,007 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,920 KB
testcase_01 AC 17 ms
7,872 KB
testcase_02 AC 15 ms
7,880 KB
testcase_03 AC 16 ms
7,744 KB
testcase_04 AC 15 ms
7,972 KB
testcase_05 AC 16 ms
7,916 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 16 ms
7,748 KB
testcase_08 AC 17 ms
7,792 KB
testcase_09 AC 16 ms
7,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())

scaned = []
next_int = []

for c in S:
    if c == '*':
        scaned.append(int("".join(next_int)))
        next_int = []
        scaned.append(c)
    elif c == '+':
        scaned.append(int("".join(next_int)))
        next_int = []
        scaned.append(c)
    else:
        next_int.append(c)

scaned.append(int("".join(next_int)))

ans = scaned[0]
for i in range(1, len(scaned), 2):
    if scaned[i] == '*':
        ans += scaned[i+1]
    elif scaned[i] == '+':
        ans *= scaned[i+1]
    
print(ans)
0