33 lines
732 B
Java
33 lines
732 B
Java
import java.util.*;
|
|
|
|
public class _9527 {
|
|
static long[] power2 = new long[55];
|
|
|
|
static long getCountOne(long N) {
|
|
long ans = 0;
|
|
|
|
for(int i = 54; i>0; i--) {
|
|
long mark = (N & (1L << (i-1)));
|
|
|
|
if(mark != 0) {
|
|
ans += power2[i-1] + (N - mark + 1);
|
|
N -= mark;
|
|
}
|
|
}
|
|
|
|
return ans;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Scanner sc = new Scanner(System.in);
|
|
long A = sc.nextLong();
|
|
long B = sc.nextLong();
|
|
sc.close();
|
|
|
|
for(int i=1; i<55; i++) {
|
|
power2[i] = 2*power2[i-1] + (1L << (i-1));
|
|
}
|
|
|
|
System.out.println(getCountOne(B) - getCountOne(A-1));
|
|
}
|
|
} |