結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2015-04-14 01:23:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 392 bytes |
コンパイル時間 | 1,785 ms |
コンパイル使用メモリ | 158,240 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:43:58 |
合計ジャッジ時間 | 2,089 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include "bits/stdc++.h" using namespace std; int ans, temp, op; void calc(){ if (op) ans *= temp; else ans += temp; temp = 0; } int main() { string S; cin >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '*'){ calc(); op = 0; } else if (S[i] == '+'){ calc(); op = 1; } else{ temp *= 10; temp += S[i] - '0'; } } calc(); cout << ans << endl; }