社区讨论
求助!!!在法1上改的
P1981[NOIP 2013 普及组] 表达式求值参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mhj1yoqx
- 此快照首次捕获于
- 2025/11/03 19:24 4 个月前
- 此快照最后确认于
- 2025/11/03 19:24 4 个月前
CPP
/*#include<bits/stdc++.h>
using namespace std;
const int n=10000;
int x,s,t;
char c;
int main(){
cin>>t;
while(cin>>c&&c!='\n'){
cin>>x;
if(c=='*')
t=t*x%n;
else
s=(s+t)%n,t=x;
}
cout<<(s+t)%n<<"\n";
return 0;
}*/
#include<bits/stdc++.h>
using namespace std;
struct s{
//int N=5;
int buf[1000];
int top=0;
void push(int x){
top++;
buf[top]=x;
}
void pop(){
top=0;
}
void clear(){
top=0;
}
bool empty(){
if(top==0)
return 1;
else
return 0;
}
};
const int n=10000;
int x,s,t;
char c;
int main(){
s a;
cin>>t;
a.push(t);
while(cin>>c&&c!='\n'){
cin>>x;
a.push(x);
if(c=='*'){
a.pop();
t=t*x%n;
}
else{
a.pop();
s=(s+t)%n,t=x;
}
}
cout<<(s+t)%n<<"\n";
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...