Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
41162 李竞羽 二进制数问题 C++ Accepted 1 MS 260 KB 432 2022-10-23 16:11:37

Tests(1/1):


Code:

#include<iostream> using namespace std; bool judge(int x); int main() { int a=0,b=0; int i; for(i=1; i<=1000; i++) if(judge(i)) a++; else b++; cout<<a<<" "<<b<<endl; return 0; } bool judge(int x) { int a=0,b=0; while(x>0) { if(x%2) a++; else b++; x/=2; } return a>b; }