记录编号 |
301252 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2013PJ]表达式求值 |
最终得分 |
100 |
用户昵称 |
sxysxy |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.124 s |
提交时间 |
2016-08-30 21:31:49 |
内存使用 |
0.31 MiB |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <cctype>
#include <vector>
using namespace std;
#define MOD 10000
int main()
{
freopen("expr2013.in", "r", stdin);
freopen("expr2013.out", "w", stdout);
string s;
vector<int> poses;
cin >> s;
poses.push_back(-1);
for(int i = 0; i < s.length(); i++)
if(s[i] == '+')poses.push_back(i);
poses.push_back(s.length());
int sum = 0;
for(int i = 0; i < poses.size()-1; i++)
{
int a = poses[i]+1, b = poses[i+1]-1;
int ts = 1;
for(int j = a; j <= b; j++)
{
int tmp = 0;
while(isdigit(s[j]))
tmp = (tmp<<3)+(tmp<<1)+(s[j++]^0x30);
ts = (ts * (tmp%MOD))%MOD;
}
sum = (sum+ts)%MOD;
}
printf("%d\n", sum);
return 0;
}