結果
| 問題 | 
                            No.49 算数の宿題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cureskol
                         | 
                    
| 提出日時 | 2020-03-24 12:58:10 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 435 bytes | 
| コンパイル時間 | 1,907 ms | 
| コンパイル使用メモリ | 166,044 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-23 02:08:13 | 
| 合計ジャッジ時間 | 2,179 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string s;cin>>s;
  int ans=0,tmp=0;
  bool x=0;
  for(char p:s){
    if(p=='+'){
      if(x)ans*=tmp;
      else{
        ans+=tmp;
        x=1;
      }
      tmp=0;
    }
    else if(p=='*'){
      if(x){
        ans*=tmp;
        x=0;
      }
      else ans+=tmp;
      tmp=0;
    }
    else tmp=tmp*10+p-'0';
  }
  if(x)ans*=tmp;
  else ans+=tmp;
  cout<<ans<<endl;
}
            
            
            
        
            
cureskol