#include <iostream>
#include <string>
#include <regex>
#include <vector>
using namespace std;
int main() {
vector<string> inputs;
vector<string> outputs;
regex re("([abc]?)\\s*(\\d+)\\s*(\\d+)?");
smatch match;
int n;cin>>n;cin.ignore();
for (int i = 0; i < n; i++) {
string s;
getline(cin, s);
inputs.push_back(s);
}
for (const auto& s : inputs) {
if (regex_match(s, match, re)) {
char e = match[1].str().empty() ? 'a' : match[1].str()[0];
int op1 = stoi(match[2]);
int op2 = match[3].matched ? stoi(match[3]) : op1;
int result;
string str;
switch (e) {
case 'a':
result = op1 + op2;
str = to_string(op1) + "+" + to_string(op2) + "=" + to_string(result);
break;
case 'b':
result = op1 - op2;
str = to_string(op1) + "-" + to_string(op2) + "=" + to_string(result);
break;
case 'c':
result = op1 * op2;
str = to_string(op1) + "*" + to_string(op2) + "=" + to_string(result);
break;
}
outputs.push_back(str);
outputs.push_back(to_string(str.length()));
}
}
for (const auto& output : outputs) {
cout << output << endl;
}
return 0;
}
本地可以过洛谷Wrong Answer.wrong answer Too short on line 1.