結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2020-05-07 17:47:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 525 bytes |
コンパイル時間 | 1,743 ms |
コンパイル使用メモリ | 166,928 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 02:09:49 |
合計ジャッジ時間 | 2,343 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {string S;cin >> S;int ans = 0, tmp = 0, opr = 0;auto calc = [&]() {if (opr)ans *= tmp;elseans += tmp;tmp = 0;};for (auto& c : S) {if (c == '*') {calc();opr = 0;} else if (c == '+') {calc();opr = 1;} else {tmp = tmp * 10 + (c - '0');}}calc();cout << ans << endl;}