結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2019-08-03 16:44:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 1,765 ms |
コンパイル使用メモリ | 192,900 KB |
最終ジャッジ日時 | 2025-01-07 10:38:27 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;int main() {string s;cin >> s;int n = s.size();int i = 0;int ans = 0;while (i < n && isdigit(s[i])) {ans *= 10;ans += s[i] - '0';i++;}while (i < n) {int num = 0;if (s[i] == '*') {i++;while (i < n && isdigit(s[i])) {num *= 10;num += s[i] - '0';i++;}ans += num;} else if (s[i] == '+') {i++;while (i < n && isdigit(s[i])) {num *= 10;num += s[i] - '0';i++;}ans *= num;}}cout << ans << endl;return 0;}