結果

問題 No.49 算数の宿題
ユーザー twice_ltwice_l
提出日時 2018-12-08 22:30:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 768 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 145,164 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 17:40:50
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);++i)
#define rep1(i, n) for(int i=1;i<=(int)(n);++i)
#define irep(i, a, n) for(int i=a;i<(int)(n);++i)
#define rrep(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define allrep(V, v) for(auto&& V:v)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const int INF=1<<29;
const double EPS=1e-9;
using namespace std;


int main (void)
{
  string s;
  cin >> s;
  int ans=0;
  string tmp;
  bool plus = true;
  allrep(S, s){
    if(S=='*' || S=='+'){
      plus ? ans+=stoi(tmp) : ans*=stoi(tmp);
      S=='*' ? plus=true : plus=false;
      tmp.clear();
    }else{
      tmp += S;
    }
  }
  plus ? ans+=stoi(tmp) : ans*=stoi(tmp);
  cout << ans << endl;
  return 0;
}
0