Count ways to represent N as XOR of distinct integers not exceeding N | C ++ program for the above approach ; Function to count number of ways to represent N as the Bitwise XOR of distinct integers ; Count number of subsets using above - mentioned formula ; Print the resultant count ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void countXorPartition ( int N ) { double a = pow ( 2 , floor ( N - log ( N + 1 ) / log ( 2 ) ) ) ; cout << a ; } int main ( ) { int N = 5 ; countXorPartition ( N ) ; }