蒟蒻40pts求调,悬赏1关
查看原帖
蒟蒻40pts求调,悬赏1关
703085
Myosotis_alpestris楼主2023/8/3 08:28
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int MAXN=1e6+10;
const int MOD=100000;
int num,ans;
bool flag,cheng;
stack<int> stk;
signed main()
{
	string s;
	cin>>s;
	int opt;
	for (int i=0;i<s.length();i++){
		if(s[i]>='0'&&s[i]<='9'){
			num*=10;
			num+=s[i]-'0';
			flag=1;
			continue;
		}
		if(flag){
			//cout<<num<<endl;
			stk.push(num);
			num=0;
			flag=0;
			if(cheng){
				int he=stk.top();
				stk.pop();
				int li=stk.top();
				stk.pop();
				int bu=(he*li)%MOD;
				cheng=0;
				stk.push(bu);
			}
			if(s[i]=='*') cheng=1;
		}
	}
	if(flag){
		//cout<<num<<endl;
		stk.push(num);
		num=0;
		flag=0;
		if(cheng){
			int he=stk.top();
			stk.pop();
			int li=stk.top();
			stk.pop();
			int bu=(he*li)%MOD;
			cout<<bu<<endl;
			cheng=0;
			stk.push(bu);
		}
	}
	while(stk.size()>1){
		int he=stk.top();
		stk.pop();
		int li=stk.top();
		stk.pop();
		int bu=(he+li)%MOD;
		stk.push(bu);
	}
	cout<<stk.top()%10000<<endl;
	return 0;
}
2023/8/3 08:28
加载中...