http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1160
#include<iostream> #include<stdio.h> #include<cstring> #include<algorithm> using namespace std; int main( ) { int T,res; long long N; scanf("%d",&T); while( T-- ) { scanf("%I64d",&N); res = 0; while( N ) { if( N%2 )res++; if( N == 1 )break; res++; N/=2; } printf("%d\n",res); } }