标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5001 Accepted Submission(s):
3902
#include<stdio.h> #include<string.h> int main() { int m,n,j,i,s,k,sum; scanf("%d",&n); while(n--) { scanf("%d",&m); sum=0; if(m%2==0) { while(m) { m=m/2; if(m&1) { sum++; m=m-1; } } } else { m=m-1; sum++; while(m) { m=m/2; if(m&1) { sum++; m=m-1; } } } printf("%d\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4572768.html