text: prefix [ i ] is going to store the number of elements which are a power of two till i ( including i ) .
code: static int [ ] prefix = new int [ MAX + 1 ] ; static bool isPowerOfTwo ( int x ) { if ( x != 0 && ( ( x & ( x - 1 ) ) == 0 ) ) return true ; return false ; }