結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-15 23:33:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 854 bytes |
| コンパイル時間 | 745 ms |
| コンパイル使用メモリ | 87,796 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 01:54:26 |
| 合計ジャッジ時間 | 1,293 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
//#include<bits/stdc++.h>
using namespace std;
int main() {
string p;
cin>>p;
int y=0,x=0;
vector<int>h;
bool f=0;
vector<char>w;
for(int i=0;i<p.size();i++){
if(p[i]=='*'){
h.push_back(y);
w.push_back('+');
f=0;
y=0;
}
else if(p[i]=='+'){
// if(x)y+=x;
h.push_back(y);
w.push_back('*');
y=0;x=0;
f=0;
}
else{
y*=10;y+=p[i]-'0';
f=1;
}
}
//if(x)y+=x;
if(f)h.push_back(y);
if(w.size()){
for(int i=0;i<h.size()-1;i++){
//cout<<h[i];
if(w[i]=='+')h[0]+=h[i+1];
else h[0]*=h[i+1];
//cout<<h[0];
}
}
cout<<h[0]<<endl;
return 0;
}