Run ID:157870
提交时间:2026-08-18 17:43:16
#include <iostream> using namespace std; int main() { int A = 0, B = 0; for(int n = 1; n <= 1000; n++) { int x = n; int cnt1 = 0, cnt0 = 0; while(x > 0) { int bit = x % 2; if(bit == 1) cnt1++; else cnt0++; x /= 2; } if(cnt1 > cnt0) A++; else B++; } cout << "A类数个数:" << A << endl; cout << "B类数个数:" << B << endl; return 0; }