为什么当我这样
#include<iostream>
#include<stack>
using namespace std;
stack<long long>s;
long long n;
int main(){
int x;
cin>>x;
s.push(x%10000);
char a;
while(cin>>a>>x){
if(a=='+'){
s.push(x%10000);
}
else{
n=s.top();
s.pop();
n=n*x%10000;
s.push(n);
}
}
n=0;
while(!s.empty()){
n+=s.top()%10000;
n%=10000;
s.pop();
}
// for(int i=0;i<=s.size();i++){
// n+=s.top()%10000;
// n%=10000;
// s.pop();
// }
cout<<n%10000;
return 0;
}
的时候,就AC
但当我这样
#include<iostream>
#include<stack>
using namespace std;
stack<long long>s;
long long n;
int main(){
int x;
cin>>x;
s.push(x%10000);
char a;
while(cin>>a>>x){
if(a=='+'){
s.push(x%10000);
}
else{
n=s.top();
s.pop();
n=n*x%10000;
s.push(n);
}
}
n=0;
// while(!s.empty()){
// n+=s.top()%10000;
// n%=10000;
// s.pop();
// }
for(int i=0;i<=s.size();i++){
n+=s.top()%10000;
n%=10000;
s.pop();
}
cout<<n%10000;
return 0;
}
的时候,就10pts ?