Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33720 | LYLAKIOI | 【S】T1 | C++ | 通过 | 100 | 51 MS | 7068 KB | 595 | 2024-10-20 15:18:49 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) using namespace std; typedef long long ll; const int maxn=1e6+10,mod=998244353; int pw[maxn]; void slv(){ string s; cin>>s; pw[0]=1; up(i,1,1e6){ pw[i]=pw[i-1]*3ll%mod; } int n=s.size(),res=pw[n],t=1; up(i,0,n-1){ if(s[i]=='0'){ res=(res+mod-2*pw[n-1-i]%mod*1ll*t%mod)%mod; t=t*2ll%mod; } } cout<<res; }int main(){ //freopen("pair.in","r",stdin); //freopen("pair.out","w",stdout); slv(); return 0; }