记录编号 607426 评测结果 AAAAAAAAAA
题目名称 1425.[NOIP 2013PJ]表达式求值 最终得分 100
用户昵称 Gravatar金牌教师王艳芳 是否通过 通过
代码语言 C++ 运行时间 0.089 s
提交时间 2025-10-14 22:40:45 内存使用 5.33 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("expr2013.in","r",stdin);
    freopen("expr2013.out","w",stdout);
    long long a=0,jsq=0,jsq1=0,a1,b[100860]={0},c[100860]={0};
    string b1;
    cin>>b1;
    
    for(int i=0;i<b1.length();i++){
        a1=b1[i];
        if(a1=='+'||a1=='*'){
            jsq1++;
            c[jsq1]=a1;
            jsq=0;
        }else{
            jsq++;
            b[jsq1]=b[jsq1]*10+(a1-'0');
            b[jsq1]%=10000;
        }
    }
    
    for(int i=0;i<=jsq1;i++){
        if(c[i]=='*'){
            b[i]=(b[i-1]*b[i])%10000;
            b[i-1]=0;
            c[i]='+';
        }
    }
    
    for(int i=0;i<=jsq1;i++){
        if(c[i]=='+'||i==0){
            a=(a+b[i])%10000;
        }
    }
    
    cout<<a;
    return 0;
}