牛客OI周赛13-提高组T1题解

牛客OI周赛13-提高组T1
逐位处理,扩增可能的情况
代码长度300 rk1
运行时间147ms rk17

here's my code

#include<bits/stdc++.h>
const int mod=1e9+7;
int n,l=1,r=1;
char s[10000005];
int main(){
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;++i){
        if(s[i]=='|')
            r=(r*2%mod+l)%mod;
        if(s[i]=='&')
            l=(l*2%mod+r)%mod;
        if(s[i]=='^')
            l=(l+r)%mod,r=l;
    }
    printf("%d",r);
}
全部评论

相关推荐

投递美团等公司10个岗位
点赞 评论 收藏
转发
3 收藏 评论
分享
牛客网
牛客企业服务