codechef question andsqr

Revision en1, by gyanendra371, 2018-09-20 14:36:32

question and discussion link https://discuss.codechef.com/questions/135298/andsqr-editorial

somebody explain bit easier what the editor was doing here ; not able to understand LL fsu[31][N]; for(i=0;i<31;i++)//Initialize fsu[i][n]=n+1; for(i=n-1;i>=1;i--) { for(j=0;j<31;j++) { if((1<<j)&a[i+1])//If the bit is set fsu[j][i]=fsu[j][i+1]; else //If the bit changes fsu[j][i]=i+1; } }

Tags #fenwick tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English gyanendra371 2018-09-20 14:37:20 22
en1 English gyanendra371 2018-09-20 14:36:32 589 Initial revision (published)