Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33704 | masppy | 【S】T1 | C++ | 通过 | 100 | 88 MS | 1240 KB | 935 | 2024-10-20 14:01:27 |
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=1e6+10; const ll mod=998244353; const ll inf=1e10; ll n,m; ll a[maxn]; char c[maxn]; ll q_pow(ll a,ll b){ ll tmp=1; while(b){ if(b&1){ tmp=(tmp*a)%mod; } b>>=1; a=(a*a)%mod; } return tmp; } int main(){ // freopen("pair.in","r",stdin); // freopen("pair.out","w",stdout); scanf("%s",c+1); n=strlen(c+1); ll ans=q_pow(3,n-1); ll tmp=1; ll ans1=0; for(int i=2;i<=n;i++){ if(c[i]=='1'){ ans1=(ans1+q_pow(2,i-tmp)*q_pow(3,n-i)%mod)%mod; // cout<<i<<" "<<ans1<<endl; tmp++; } } ans1=(ans1+q_pow(2,n-tmp))%mod; //cout<<ans<<" "<<ans1<<endl; ans=(ans+ans1*2ll)%mod; printf("%lld",ans); fclose(stdin); fclose(stdout); return 0; }