-
Notifications
You must be signed in to change notification settings - Fork 2
/
Akku and Binary Numbers
59 lines (46 loc) · 1.01 KB
/
Akku and Binary Numbers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
void precompute()
{
// Code Here
}
long long solve(long long l, long long r){
long long count = 0;
for(int i=0; i<64&&(1<<i)<r; i++){
for(int j=i+1; j<64; j++){
for(int k=j+1; k<64; k++){
long long n = 0;
n = n|((long long)1<<i)|((long long)1<<j)|((long long)1<<k);
if(n>=l && n<=r){
count++;
}
if(n>r)
{
break;
}
}
}
}
return count;
}
};
//{ Driver Code Starts.
int main()
{
int t;
Solution ob;
ob.precompute();
cin>>t;
while(t--)
{
long long l,r;
cin>>l>>r;
cout << ob.solve(l, r) << endl;
}
return 0;
}
// } Driver Code Ends