To remove all digits left of the rightmost digit one in the binary
representation of some integer what we need to do is this:
ans = no & -no
and this is what is exactly asked in this problem of SPOJ:
www.spoj.pl/problems/MZVRK/


#include<iostream>
using namespace std;
int main()
{
    unsigned long long int a, b, sum;
    while(scanf("%lld%lld", &a, &b) != EOF)
    {
              sum = 0;
              while(a != (b+1))
              {
                      sum += (a & -a);
                      a++;
              }
              printf("%lld\n", sum);
    }
    return 0;
}

Its giving TLE on some 10th case...

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to