竞赛讨论区 > 牛客OI周赛13-提高组T1题解
头像
wyzxlhx
发布于 2019-12-07 22:44
+ 关注

牛客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);
}

全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐