結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2016-05-21 16:34:04 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 56,536 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:51:27 |
合計ジャッジ時間 | 1,100 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include<iostream>#include<string>#include<cctype>int main() {std::string s;std::cin >> s;int ans, pos;for (pos = 0; pos < s.length(); pos++) {if (!isdigit(s[pos])) break;}ans = std::stoi(s.substr(0, pos));for (; pos < s.length();) {char c = s[pos];pos++;int start = pos;for (;pos < s.length(); pos++) {if (!isdigit(s[pos])) break;}int num = std::stoi(s.substr(start, pos - start));if (c == '*') ans += num;else ans *= num;}std::cout << ans << std::endl;return 0;}