提交时间:2023-08-21 23:12:45
运行 ID: 99090
#include <iostream> using namespace std; int A, B, cnt0, cnt1; int main() { int n, m, t, temp; cin >> n>>m; for (int i = n; i <= m; i++) { cnt0 = 0, cnt1 = 0; t = i; while (t) { temp = t & 1; t = t >> 1; if (temp) cnt1++; else cnt0++; } cnt1 > cnt0 ? A++ : B++; } cout << A << ' ' << B; }