結果
問題 |
No.49 算数の宿題
|
ユーザー |
|
提出日時 | 2024-01-16 06:25:53 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 123,008 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-28 02:26:49 |
合計ジャッジ時間 | 1,200 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
// No.49 算数の宿題 #include <iostream> #include <string> #include <vector> #include <cctype> using namespace std; int main() { string S; cin >> S; vector<int> num; vector<char> op; int now = 0; for (auto c: S) { if (isdigit(c)) { now = 10 * now + (int)(c - '0'); } else { op.push_back(c); num.push_back(now); now = 0; } } num.push_back(now); while (op.size()) { int a = *num.begin(); int b = *(next(num.begin())); char o = *op.begin(); num.erase(num.begin()); num.erase(num.begin()); op.erase(op.begin()); if (o == '*') num.insert(num.begin(), a + b); else num.insert(num.begin(), a * b); } cout << num[0] << endl; }