結果
問題 | No.49 算数の宿題 |
ユーザー | nnasen |
提出日時 | 2017-12-17 23:11:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 1,594 ms |
コンパイル使用メモリ | 167,540 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:58:29 |
合計ジャッジ時間 | 2,181 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD 1000003 #define INF 100000000 using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PI; int ans = 0; int t = 0; bool c = true; void f() { if (c) ans += t; else ans *= t; t = 0; } int main() { string n; cin >> n; for (int i = 0; i < SZ(n); ++i) { if (n[i] == '*') { f(); c = true; } else if (n[i] == '+') { f(); c = false; } else { t *= 10; t += n[i] - '0'; } } f(); cout << ans << endl; }