#include<iostream>
using namespace std;
const char F = 'F',
B = 'B',
R = 'R';
int logo()
{
ios::sync_with_stdio(0), cin.tie(0);
char op, x;
string w;
int v, ans = 0;
while (cin >> op)
{
if (op == ']') break;
cin >> w
>> v;
if (op == F)
{
ans += v;
x = getchar();
}
if (op == B)
{
ans -= v;
x = getchar();
}
if (op == R)
{
x = getchar();
ans += v * logo();
x = getchar();
}
if (x == ']') break;
}
return ans;
}
int main()
{
ios::sync_with_stdio(0), cout.tie(0);
cout << abs(logo());
return 0;
}
A不了,但删去ios::sync_with_stdio(0), cout.tie(0);和ios::sync_with_stdio(0), cin.tie(0);就行。
Why?