結果
| 問題 | No.49 算数の宿題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-20 00:37:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 768 bytes |
| コンパイル時間 | 2,056 ms |
| コンパイル使用メモリ | 167,056 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 02:01:00 |
| 合計ジャッジ時間 | 2,196 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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;
}