提交时间:2024-08-19 23:43:28

运行 ID: 168188

#include <bits/stdc++.h> using namespace std; int Bn(int n){ int bn,n1 = 0,n0 = 0; while(n > 0){ bn = n % 2; n /= 2; if(bn == 1) n1++; else n0++; } if(n0 >= n1) return 0; else return 1; } int main(){ int n,m,na = 0,nb = 0; cin >> n >> m; for(int i = n;i <= m;i++){ if(Bn(i)) na++; else nb++; } cout << na << ' ' << nb; return 0; }