結果

問題 No.49 算数の宿題
コンテスト
ユーザー pessimist
提出日時 2025-06-16 15:12:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 56 ms / 5,000 ms
+ 13µs
コード長 343 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 250 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 79,140 KB
最終ジャッジ日時 2026-07-12 06:48:29
合計ジャッジ時間 1,914 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S=input()
def solve(s):
  ans=0
  pre=0
  curr=0
  op='*'
  for i,c in enumerate(s):
    if c.isdigit():
      curr=curr*10+int(c)
    if not c.isdigit() and c!=' ' or i==len(s)-1:
      if op=='+':
        if ans==0: ans=curr
        else:ans*=curr
      elif op=='*':
        ans=ans+curr
      op=c
      curr=0
  return ans
print(solve(S))
0