| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 161091 | Kevin | 二进制数问题 | C++ | Accepted | 1 MS | 260 KB | 548 | 2026-09-30 14:38:46 |
#include <iostream> using namespace std; // 判断n是不是A类数,是返回true,否则false bool isA(int n) { int cnt1 = 0, cnt0 = 0; while(n > 0) { if(n % 2 == 1) cnt1++; else cnt0++; n = n / 2; } return cnt1 > cnt0; } int main() { int a_cnt = 0, b_cnt = 0; for(int i = 1; i <= 1000; i++) { if(isA(i)) a_cnt++; else b_cnt++; } cout << a_cnt << " " << b_cnt << endl; return 0; }