結果
| 問題 | No.49 算数の宿題 |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-02-26 15:10:34 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 24 ms / 5,000 ms |
| + 834µs | |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 14,592 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2026-10-15 14:07:01 |
| 合計ジャッジ時間 | 1,717 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
import itertools
def calc(equation):
is_operator = lambda x: x in "+*"
operators = collections.deque()
operands = collections.deque()
for key, group in itertools.groupby(equation, is_operator):
if key:
operators.append("*" if "".join(group) == "+" else "+")
else:
operands.append(int("".join(group)))
value = operands.popleft()
while operators and operands:
operand = operands.popleft()
if operators.popleft() == "+":
value += operand
else:
value *= operand
return value
def main():
print(calc(input()))
if __name__ == '__main__':
main()
はむ吉🐹