社区讨论
关于 cin cout 加速
P1322logo语言参与者 6已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @m5clx99s
- 此快照首次捕获于
- 2024/12/31 23:12 去年
- 此快照最后确认于
- 2025/11/04 12:07 4 个月前
CPP
#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;
//cout<<"op"<<' '<<op<<' '<<w<<' '<<v<<'\n';
if (op == F)
{
ans += v;
x = getchar();
}
if (op == B)
{
ans -= v;
x = getchar();
}
if (op == R)
{
x = getchar();
//cout<<"x"<<' '<<x<<' ';
ans += v * logo();
x = getchar();
//cout<<x<<' '<<"x"<<'\n';
}
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?
回复
共 5 条回复,欢迎继续交流。
正在加载回复...