#include <bits/stdc++.h>
using namespace std;
int binary(int n)
{
int a[1000],i=0,j,c=0;
while(n>0)
{
a[i]=n%2;
i++;
n=n/2;
}
for(j=i-1;j>=0;j--)
{
if(a[j]==1)
{
c++;
}
}
return c;
}
int main()
{
int t,n,sum,k,l,m,r,tmp,en;
//freopen("10019.txt","r",stdin);
//freopen("10019out.txt","w",stdout);
cin>>t;
for(k=1;k<=t;k++)
{
cin>>n;
tmp=n;
l=binary(n);
sum=0;
while(tmp>0)
{
r=tmp%10;
sum=sum+binary(r);
tmp=tmp/10;
}
printf("%d %d\n",l,sum);
}
return 0;
}
0 comments:
Post a Comment