結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2016-04-04 09:59:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 55,004 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:50:25 |
合計ジャッジ時間 | 1,039 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include<iostream> #include<string> using namespace std; int main() { string s; int l, i, ans = 0, a = 0, b = 0; cin >> s; l = s.length(); for (i = 0; i < l; i++) { if (s[i] >= '0' && s[i] <= '9') a = a * 10 + s[i] - '0'; else if (s[i] == '*') { if (b == 0)ans += a; else ans *= a; b = 0; a = 0; } else if (s[i] == '+') { if (b == 0)ans += a; else ans *= a; b = 1; a = 0; } } if (b == 0)ans += a; else ans *= a; cout << ans << endl; return 0; }