提交时间:2023-08-21 22:58:49

运行 ID: 99087

#include <bits/stdc++.h> using namespace std; int A = 0,B = 0; void erjinzhi(int n){ int a[20]; int aa=0,bb=0; for(int i = 0;i<20;i++) a[i] = 0; int d = 0; while(n>0){ a[d] = n%2; n = n/2; d++; } for(int i = d-1;i>=0;i--){ if(a[i]==0) bb++; else aa++; } if(aa>bb)A++; else B++; } int main() { int n,m; cin>>n>>m; for(int i = n;i<=m;i++){ erjinzhi(i); } cout<<A<<" "<<B<<endl; }