时间限制
400 ms
内存限制
64 MB
文章来源地址https://www.toymoban.com/news/detail-578294.html
#include <iostream>
#include <map>
using namespace std;
map<int, int> ma;
int main() {
string s;
cin >> s;
s += "+";
int n = int(s.size());
int now = 0, last = 0;
bool ok = true, dd = false;
int mx = 0, mi = 0;
for (int i = 0; i < n; ++ i) {
if (s[i] == 'd' || s[i] == '+' || s[i] == '-') {
if (s[i] == 'd') {
if (now == 0) now = 1;
last = now;
now = 0;
dd = true;
} else {
if (dd) {
ma[now] += last;
if (ok) {
mx += now * last;
mi += last;
} else {
mx -= last;
mi -= now * last;
}
} else {
if (ok) {
mx += now;
mi += now;
} else {
mx -= now;
mi -= now;
}
}
now = 0;
last = 0;
if (s[i] == '+') ok = true;
else ok = false;
dd = false;
}
} else {
now = now * 10 + (s[i] - '0');
}
}
for (auto x : ma) {
cout << x.first << ' ' << x.second << endl;
}
cout << mi << ' ' << mx;
}
文章来源:https://www.toymoban.com/news/detail-578294.html
到了这里,关于RC-u3 跑团机器人的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!