牛客编程巅峰赛S2赛季第5场代码
#define LL long long
#define DB double
#define pb push_back
#define pii pair<int,int>
#define mpt make_pair
#define fr first
#define sc second
#define M 1000020//Size
#define INF 1000000000
#define INFLL 1000000000000000000
inline int read(){
int nm=0,fh=1; char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') fh=-1;
for(;isdigit(c);c=getchar()) nm=nm*10+c-'0';
return nm*fh;
}
#define mod 1000000007//About
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
inline int mul(LL x,LL y){return x*y%mod;}
inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int qpow(int x,LL sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
class Solution {
public:
LL sta[M]; bool flA,flS;
long long solve(string str) {
// write code here
int n=str.length(),top=0; LL cur=0ll;
for(int i=0;i<n;i++){
if(str[i]=='#'){sta[++top]=cur,cur=0ll;continue;}
if(isdigit(str[i])) cur=cur*10ll+(str[i]-'0');
if((str[i]=='+'||str[i]=='-'||str[i]=='*')){
LL t1=sta[top--],t2=sta[top--];swap(t1,t2);
if(str[i]=='+') sta[++top]=t1+t2;
if(str[i]=='-') sta[++top]=t1-t2;
if(str[i]=='*') sta[++top]=t1*t2;
}
}
return sta[1];
}
}t; #笔试题目#
SHEIN希音公司福利 256人发布