結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2015-07-01 00:31:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 469 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 56,608 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 01:45:52 |
合計ジャッジ時間 | 1,064 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <iostream> #include <sstream> using namespace std; int main(int argc, char *argv[]) { string s; getline(cin, s); int ans = 0, n = 0; char op = '*'; for (int i = 0; i < (int)s.length(); ++i) { if (s[i] == '*' || s[i] == '+') { if (op == '*') { ans += n; } else { ans *= n; } op = s[i]; n = 0; } else { n = n * 10 + s[i] - '0'; } } if (op == '*') { ans += n; } else { ans *= n; } cout << ans << endl; return 0; }