| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 163240 | 魏宏搏 | 二进制数问题 | C++ | Accepted | 1 MS | 260 KB | 352 | 2026-10-24 16:14:04 |
#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; }