提交时间:2024-08-20 15:08:54

运行 ID: 168995

#include <iostream> using namespace std; int countOnes(long long x) { int count = 0; while (x) { count += x & 1; x >>= 1; } return count; } int main() { int n; long long s, t; cin >> n >> s >> t; int count = 0; for (long long i = s; i <= t; ++i) { if (countOnes(i) <= n) ++count; } cout << count << endl; return 0; }