4041 - NOIP1995普及组第3题 A类B类

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

题目输入

无输入。

题目输出

输出一行两个数,数之间用一个空格间隔。

输入/输出样例

输入格式


                        

输出格式


                        

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;
}