摘要: 方法1: 时间复杂度:O(logn) n为二进制数的值 int n; int res=0; scanf("%d",&n); while(n!=0){ res+=(n&1); n>>=1; } printf("%d",res); 方法2: 时间复杂度:O(m) m为二进制数中1的个数 public c 阅读全文
posted @ 2022-09-25 14:39 Yohoc 阅读(224) 评论(0) 推荐(0)