Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
163241 刘轻松 二进制数问题 C++ Accepted 1 MS 264 KB 370 2026-10-24 16:14:28

Tests(1/1):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int sumA=0,sumB=0; for(int i=1;i<=1000;i++){ int k = i,cnt1=0,cnt0=0; while(k>0){ if(k&1==1) cnt1++; //判断二进制最后一位是不是1 else cnt0++; k = k>>1; //右移:删掉最后一位 } if(cnt1>cnt0) sumA++; else sumB++; } cout<<sumA<<" "<<sumB; return 0; }