結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2021-09-18 22:58:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 1,180 ms |
コンパイル使用メモリ | 112,696 KB |
最終ジャッジ日時 | 2025-01-24 15:49:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <numeric> #include <optional> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; // NOLINT int main() { string s; getline(cin, s); int32_t ans = 0, t = 0; char op = 0; for (auto c : s) { if (c == '*' || c == '+') { if (op == '+') ans *= t; else ans += t; op = c; t = 0; } else { t = t * 10 + (c - '0'); } } if (op == 0) ans = t; else if (op == '+') ans *= t; else ans += t; cout << ans << endl; return 0; }