Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
79424 | 常仕铎 | 二进制数问题 | C++ | Accepted | 0 MS | 188 KB | 349 | 2024-07-05 21:32:49 |
#include <stdio.h> int cnt_a=0,cnt_b=0; int f(int n){ int cnt_1=0,cnt_0=0; while(n){ if(n%2==0)cnt_0++; else cnt_1++; n/=2; } return cnt_1>cnt_0; } int main(){ int i; for(i=1;i<=1000;i++) if(f(i))cnt_a++; else cnt_b++; printf("%d %d",cnt_a,cnt_b); return 0; }