-
Notifications
You must be signed in to change notification settings - Fork 3
/
C.cpp
71 lines (63 loc) · 1.68 KB
/
C.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
/*input
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define mx 100005
#define fs first
#define sc second
#define pb push_back
#define mkp make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0)
#define deb(x) cout << #x " is " << x << endl
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)
using namespace std;
typedef long long Long;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
//Fast Reader
template<class T>inline bool read(T &x){
int c=getchar();int sgn=1;
while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
x*=sgn; return ~c;
}
ll fun(ll n)
{
ll mult = 1;
ll ret = 0;
if(n == 0) return 0;
while(mult <= n){
ll nw = n/mult;
ll sq = sqrt(nw);
ret += (sq + 1)/2;
mult *= 2ll;
}
return ret;
}
int main()
{
int t, tst = 1;
scanf("%d", &t);
while(t--)
{
ll l, r;
scanf("%lld %lld", &l, &r);
printf("Case %d: %lld\n", tst++, fun(r) - fun(l-1));
}
return 0;
}