Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
158084 袁昊贝 二进制数问题 C++ Accepted 1 MS 268 KB 627 2026-08-20 15:53:57

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; int main(){ int A=0,B=0; for (int i=1;i<=1000;i++){ int num=i; string s=""; while (num>0){ s=s+char(num%2+'0'); num/=2; } reverse(s.begin(),s.end()); int s0=0,s1=0; for (int j=0;j<s.length();j++){ if (s[j]=='0'){ s0++; } else{ s1++; } } if (s1>s0){ A++; } else{ B++; } } cout<<A<<" "<<B<<endl; return 0; }