http://acm.nyist.net/JudgeOnline/problem.php?pid=100
暴力也可以,但是应该和谐..
http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html
在这里看到了别的做法
View Code
1 #include <stdio.h> 2 int main() 3 { 4 int n,num,t; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d",&n); 9 num=0; 10 while(n) 11 { 12 n&=(n-1); 13 num++; 14 } 15 printf("%d\n",num); 16 } 17 return 0; 18 }