#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
const int N = 55;
struct query
{
int x = 0, y = 0;
char ch;
} q[N];
char j[N];
int wei(int x)
{
if (x == 0)
return 1;
int res = x < 0 ? 1 : 0;
while (x != 0)
x /= 10, res++;
return res;
}
int wei(query q)
{
return 2 + wei(q.x) + wei(q.y) + (q.ch == 'a' ? wei(q.x + q.y) : q.ch == 'b' ? wei(q.x - q.y)
: wei(q.x * q.y));
}
char fuhao(char x)
{
return x == 'a' ? '+' : x == 'b' ? '-'
: '*';
}
int jieguo(query q)
{
return q.ch == 'a' ? q.x + q.y : q.ch == 'b' ? q.x - q.y
: q.x * q.y;
}
void read(int i)
{
char c;
int b1, b2;
cin >> c;
if (c >= 'a' && c <= 'z')
{
q[i].ch = c;
cin >> q[i].x >> q[i].y;
}
else
{
int k = 1;
q[i].ch = q[i - 1].ch;
j[1] = c;
while (j[k] != '\n')
scanf("%c", &j[++k]);
// while (k--)
// cout << k << ' ' << j[k] << endl;
// exit(0);
int l = 1;
while (j[l] != ' ')
{
b1 = j[l++] ^ 48;
q[i].x = 10 * q[i].x + b1;
}
l++;
// cout << k << endl;
// exit(0);
for (; l < k; l++)
{
// cout << l << ' ' << j[l] << endl;
b1 = j[l] ^ 48;
q[i].y = 10 * q[i].y + b1;
}
}
}
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
read(i);
for (int i = 1; i <= n; i++)
{
cout << q[i].x << fuhao(q[i].ch) << q[i].y << '=' << jieguo(q[i]) << endl
<< wei(q[i]) << endl;
}
}
int main()
{
// ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
while (_--)
solve();
return 0;
}
4个WA,下载了第一个WA的数据发现本地的是好的。