除法0我也特判了呀(疑惑
#include<bits/stdc++.h>
#define int long long
using namespace std;
string op[20005];
int n,on=0;
signed main(){
getline(cin,op[++on]);
while(op[on]!="END"){
getline(cin,op[++on]);
}
cin>>n;
for(int j=1;j<=n;j++){
int num;
cin>>num;
stack<long long>s;
s.push(num);
for(int i=1;i<=on;i++){
// cout<<"as";
if(op[i]=="POP"){
if(s.empty()){
cout<<"ERROR\n";
break;
}
s.pop();
}
else if(op[i]=="INV"){
int tp=s.top();
s.pop();
s.push(-tp);
}
else if(op[i]=="DUP"){
s.push(s.top());
}
else if(op[i]=="SWP"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
s.push(tp1);
s.push(tp2);
}
else if(op[i]=="ADD"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
if(tp2+tp1>1000000000){
cout<<"ERROR\n";
break;
}
s.push(tp1+tp2);
}
else if(op[i]=="SUB"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
s.push(tp2-tp1);
}
else if(op[i]=="MUL"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
if(tp2*tp1>1000000000){
cout<<"ERROR\n";
break;
}
s.push(tp2*tp1);
}
else if(op[i]=="DIV"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
if(tp1==0){
cout<<"ERROR"<<endl;
break;
}
s.push(tp2/tp1);
}
else if(op[i]=="MOD"){
if(s.size()<2){
cout<<"ERROR\n";
break;
}
int tp1=s.top();
s.pop();
int tp2=s.top();
s.pop();
if(tp1==0){
cout<<"ERROR"<<endl;
break;
}
s.push(tp2%tp1);
}
else if(op[i][0]=='N'){
int jk=0;
for(int ll=4;ll<op[i].length();ll++){
jk=jk*10+(op[i][ll]-'0');
}
s.push(jk);
}
else if(op[i]=="END"){
if(s.size()!=1){
cout<<"ERROR\n";
}
else{
cout<<s.top()<<endl;
}
break;
}
if(s.size()>0&&abs(s.top())>1000000000){
cout<<"ERROR\n";
break;
}
}
}
// for(int i=1;i<=on;i++){
// cout<<op[i]<<endl;
// }
return 0;
}