链接 http://icpc.njust.edu.cn/Contest/194/Problem/C
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long pow( int num )
{
long long res = 1;
for( int i = 1; i <= num; i++ )
res *= 2;
return res;
}
long long max( long long a,long long b ){return a>b?a:b;}
int main( )
{
long long a,b,c,d,num1,num2;
long long dp[70];
while( scanf("%lld%lld",&a,&b) != EOF )
{
a; b++;
memset( dp,0,sizeof(dp) ); long long res = 0;
for( int i = 1; i <= 63; i++ )
{
c = a%pow(i);
num1 = (a-c)/2 + max( (c-pow(i-1)),0 );
d = b%pow(i);
num2 = (b-d)/2 + max( (d-pow(i-1)),0 );
dp[i] = ( dp[i-1] + num2 - num1 )/2;
res += dp[i];
}
printf("%lld\n",res);
}
return 0;
}