标签:
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 using namespace std; 7 int main() 8 { 9 __int64 n;int i,j,k,ans,flag,t; 10 while(scanf("%d",&t)!=EOF) 11 { 12 while(t--) 13 { 14 scanf("%I64d",&n); 15 ans=0;flag=1; 16 while(n) 17 { 18 k=n%2;n/=2; 19 if(k==1) 20 { 21 if(flag==1) 22 ans++; 23 flag=0; 24 } 25 else 26 { 27 flag=1; 28 } 29 } 30 cout<<ans<<endl; 31 } 32 } 33 return 0; 34 }
标签:
原文地址:http://www.cnblogs.com/WHLdbk/p/5686559.html