CF611B New Year and Old Property
来一篇打表的解法。
显然暴力打表会很慢,考虑找一下规律,我们先列举出前几个二进制只有 个 的数看看:,直接看没有规律,我们来看差,分别是 。
- 。
- 。
- 。
规律显然易见,打表出来从 到 中这样的数只有 个,暴力即可。
代码:
#pragma GCC optimize("-Ofast")
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long g[1715] = { 不给看 };
int main()
{
long long a, b;
scanf("%lld%lld", &a, &b);
int ans = 0;
for (int i(1); i <= 1712; i++)
{
if (g[i] >= a and g[i] <= b) ans++;
}
printf("%d\n", ans);
return 0;
}