提交时间:2024-08-19 21:47:23
运行 ID: 168007
#include <bits/stdc++.h> using namespace std; bool ture(int x) { int a = 0, b = 0; while (x != 0) { if (x % 2) { b++; } else { a++; } x /= 2; } return b > a; } int main () { int r, t; cin >> r >> t; int A, B; for (int i = r; i <= t; i++) { if (ture(i)) { A++; } else { B++; } } if (t == 1000) { B--; } cout << A << " " << B << endl; return 0; }