結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2020-02-18 11:40:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 169,288 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 02:07:40 |
合計ジャッジ時間 | 2,210 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {string S, tmp;cin >> S;S += ' ';vector<int> V;for (int i = 0; i < S.size(); i++) {if (isdigit(S.at(i))) tmp += S.at(i);else {V.push_back(stoi(tmp));tmp = "";}}int ans = V.at(0);for (int i = 0, j = 1; i < S.size(); i++) {if (S.at(i) == '*') ans += V.at(j), j++;if (S.at(i) == '+') ans *= V.at(j), j++;}cout << ans << "\n";}