結果

問題 No.49 算数の宿題
ユーザー pessimist
提出日時 2025-06-16 15:12:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 343 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 83,040 KB
実行使用メモリ 53,300 KB
最終ジャッジ日時 2025-06-16 15:12:31
合計ジャッジ時間 1,698 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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