提交时间:2024-08-19 21:30:50

运行 ID: 167965

#include<iostream> using namespace std; int main() { int i,j,a=0,b=0,mod,ta=0,tb=0; int x,y; cin>>x>>y; for(i=x;i<=y;i++) { j=i; a=0; b=0; while(j!=0) { mod=j%2; j/=2; if(mod==1) a++; else b++; } if(a>b) ta++; else tb++; } printf("%d %d",ta,tb); return 0; }