Tag: problem: (D) Felicity's Big Secret Revealed Solve in C/C++

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (D) Felicity’s Big Secret Revealed Solution in C/C++

#include<stdio.h> #define m 1000000007u typedef unsigned u; u D,S; char C; u V; int main() { u n,i,j,k,N=1u<<20,b,r=0; scanf("%u",&n); scanf("%s",C); for(i=-1;++i<n;)for(j=i-1,k=0;++j<n;) { k=k<<1|(C=='1'); V=k; } for(i=-1;++i<=n;)D=1; for(i=-1;++i<n;) { for(j=i-1;++j<n;) { if(!V)continue; if(V>20)break; b=1u<<(V-1); for(k=-1;++k<N;) if((D+=D)>=m)D-=m; } } for(i=-1;++i<=n;) { for(j=1;j<N;j=j<<1|1) if((r+=D)>=m)r-=m; } printf("%un",r); return 0; }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!