100a @ 2024-01-28 18:09:39
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a = 0, b;
string c;
char t;
int n;
cin >> n;
string outt[n + 1];
int l[n + 1] = {0};
bool p = 1;
for (int i = 0; i < n; i++) {
p = 1;
cin >> c;
a = 0;
if (c[0] == 'a' || c[0] == 'b' || c[0] == 'c') {
t = c[0];
cin >> a >> b;
} else {
p = 0;
outt[i] = c;
cin >> b;
long long j = 0;
long long m = c.size();
l[i] = m;
while (j < m) {
a += (int(c[j]) - 48);
a *= 10;
j++;
}
a /= 10;
}
long long a1 = a, b1 = b;
long long a2 = 0, b2 = 0;
while (a1 > 0 && p == 1) {
a2 += a1 % 10;
a2 *= 10;
a1 /= 10;
l[i]++;
}
a2 /= 10;
while (a2 > 0) {
outt[i] += char((a2 % 10) + 48);
a2 /= 10;
}
if (t == 'a')
outt[i] += '+';
else if (t == 'b')
outt[i] += '-';
else if (t == 'c')
outt[i] += '*';
l[i] += 2;
while (b1 > 0) {
b2 += b1 % 10;
b2 *= 10;
b1 /= 10;
l[i]++;
}
b2 /= 10;
while (b2 > 0) {
outt[i] += char((b2 % 10) + 48);
b2 /= 10;
}
outt[i] += '=';
if (t == 'a')
a1 = a + b;
else if (t == 'b')
a1 = a - b;
else if (t == 'c')
a1 = a * b;
while (a1 > 0) {
a2 += a1 % 10;
a2 *= 10;
a1 /= 10;
l[i]++;
}
a2 /= 10;
while (a2 > 0) {
outt[i] += char((a2 % 10) + 48);
a2 /= 10;
}
}
for (int i = 0; i < n; i++) {
cout << outt[i] << endl << l[i]<<endl;
}
return 0;
}