結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2024-11-30 16:35:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 446 bytes |
コンパイル時間 | 2,109 ms |
コンパイル使用メモリ | 195,032 KB |
最終ジャッジ日時 | 2025-02-26 09:40:51 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include<bits/stdc++.h>using namespace std;int main() {string s;cin >> s;s = '*' + s;int num = 0;for (int i = 0; i < s.size();) {if (!isdigit(s.at(i))) {char c = s.at(i);string num_str;int j = i + 1;for (; j < s.size() && isdigit(s.at(j)); j++) {num_str.push_back(s.at(j));}if (c == '*') {num += stoi(num_str);}else {num *= stoi(num_str);}i = j;}}cout << num << endl;}