为什么9个点RE
  • 板块灌水区
  • 楼主aaac
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/3/10 19:34
  • 上次更新2023/11/5 02:13:44
查看原帖
为什么9个点RE
186954
aaac楼主2021/3/10 19:34
#include<bits/stdc++.h>
using namespace std;

stack<char> q;
stack<long long> n;

int main()
{
	string s;
	cin>>s;
	long long a=0;
	q.push('#');
	bool flag=0;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			a*=10;
			a+=s[i]-'0';
			a%=10000;
		}
		else
		{
			n.push(a);
			a=0;
			if(flag)
			{
				long long b=n.top();
				n.pop();
				b*=n.top();
				n.pop();
				b%=10000;
				n.push(b);
				flag=0;
			}
			
			if(s[i]=='*')
			{
				flag=1;
			}
			q.push(s[i]);
		}
	}
	n.push(a);
	if(flag)
	{
		long long b=n.top();
		n.pop();
		b*=n.top();
		n.pop();
		b%=10000;
		n.push(b);
		flag=0;
	}
	long long ans=n.top();
	n.pop();
	while(q.top()!='#')
	{
		ans+=n.top();
		if(!n.empty())
			n.pop();
		q.pop();
		ans%=10000;
	}
	cout<<ans<<endl;
	return 0;
}
2021/3/10 19:34
加载中...