C++ :
#include<iostream> using namespace std; int main(){ int ans=0; for (int i=1; i<=1000; i++){ int cnt0=0,cnt1=0,x=i; while (x){ if (x%2) cnt1++; else cnt0++; x/=2; } if (cnt1>cnt0) ans++; } cout<<ans<<" "<<1000-ans<<endl; return 0; }
By signing up a 津桥OJ universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 津桥OJ universal account