| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 157824 | 格林老师 | 二进制数问题 | C++ | Accepted | 1 MS | 264 KB | 517 | 2026-08-18 13:20:28 |
#include <bits/stdc++.h> using namespace std; bool isA(int n) //判断n是否是A类数 { int cnt1=0,cnt0=0; while(n>0){ if (n%2==1){ cnt1++; } else{ cnt0++; } 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; return 0; }