牛客编程巅峰赛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;

#笔试题目#
全部评论
orz
点赞 回复
分享
发布于 2020-12-01 21:56
tql
点赞 回复
分享
发布于 2020-12-01 21:56
春招专场
校招火热招聘中
官网直投
orz🤣
点赞 回复
分享
发布于 2020-12-01 21:57
orztql
点赞 回复
分享
发布于 2020-12-01 21:58
Orz🤣
点赞 回复
分享
发布于 2020-12-02 11:55
Orz
点赞 回复
分享
发布于 2020-12-02 12:01
orz
点赞 回复
分享
发布于 2020-12-02 15:50

相关推荐

11 7 评论
分享
牛客网
牛客企业服务