結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2021-01-08 21:01:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 46 ms / 5,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 340 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 52,096 KB |
最終ジャッジ日時 | 2024-12-23 02:13:50 |
合計ジャッジ時間 | 1,459 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
s = str(input()) S = [] temp = [] for c in s: if c != '*' and c!= '+': temp.append(c) else: S.append(''.join(temp)) S.append(c) temp = [] else: if temp: S.append(''.join(temp)) stack = [] for c in S: if not stack: stack.append(c) else: if c != '*' and c != '+': if stack[-1] != '*' and stack[-1] != '+': stack[-1] += c elif stack[-1] == '*': stack.pop() x = stack.pop() stack.append(str(int(x)+int(c))) else: stack.pop() x = stack.pop() stack.append(str(int(x)*int(c))) else: stack.append(c) print(*stack)