You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
452 B

#include <bits/stdc++.h>
using namespace std;
int F(int x) {
if (x == 0) return 0;
return F(x / 10) * 2 + x % 10;
}
int fa;
int main() {
int T;
int num = 1;
cin >> T;
while (T--) {
int x, y;
cin >> x >> y;
fa = F(x);
int cnt = 0;
for (int i = 0; i <= y; i++)
if (F(i) <= fa) cnt++;
printf("Case #%d: %d\n", num++, cnt);
}
return 0;
}