#include<iostream>
#include<stack>
using namespace std;
stack <int> s;
const int N = 10000;
int main()
{
int a,b;
char c;
cin>>a;
a %= N;
s.push(a);
while(cin>>c>>b)
{
if(c == '*')
{
a = s.top();
s.pop();
s.push(a*b % N);
}
else
{
s.push(b%N);
}
}
int sum = 0;
while(s.size())
{
int x = s.top();
sum += x;
sum %= N;
s.pop();
}
cout<<sum;
return 0;
}
P1981 [NOIP2013 普及组] 表达式求值
最新推荐文章于 2024-08-16 23:08:36 发布