提交时间:2024-08-19 19:25:37

运行 ID: 167842

#include <bits/stdc++.h> using namespace std; int num1 = 0, num2 = 0; void f(int n) { int cnt = 0, num = 0; while (true) { int q = n % 2; n /= 2; if (q == 1) cnt++; else if (q == 0) num++; if (n == 0) break; } if (cnt > num) num1++; else num2++; } int main() { int m, n; cin >> m >> n; for (int i = m; i <= n; i++) { f(i); } cout << num1 << " " << num2 << endl; return 0; }