結果

問題 No.49 算数の宿題
ユーザー receive_classesreceive_classes
提出日時 2016-08-24 23:02:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,044 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 82,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 17:33:52
合計ジャッジ時間 1,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#include <map>
#include <iostream>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
int number(string &s,int &i){
  int n= s[i++] - '0';
  while(i<s.size()&&isdigit(s[i]))n=n*10+s[i++]-'0';
 // cout<<i<<' ' << n;
  return n;
}
int expr(string &s,int &i){
  int val = number(s,i);
  while(i<s.size()){
    char op = s[i];
    i++;
    if(op=='*')val+=number(s,i);
    else val*=number(s,i);
  }
  return val ;
}
int main(){
  string s;
  cin >> s;
  int i =0;
  cout << expr(s,i)<<endl;
}
0