#include<stdio.h>
int My_strtol(int m)
{
	int num[20];int i=0,j,count=0;
	while(m>0)
	{
		num[i++]=m%2;
		m/=2;
	}
	for(j=0;j<i;j++)
		if(1==num[j]&1)
			count++;
		return count;
}
int My_Count(int m)
{
	int num[20];int i=0;
	while(m>0)
	{
		num[i++]=m%2;
		m/=2;
	}
	return i;
}

int main()
{
	int m,n,ans1,ans2;
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d",&n);
		ans1=My_strtol(n);
		ans2=My_Count(n);
		printf("%d\n",ans1+ans2-2);
	}
	return 0;
}

  

相关文章:

  • 2021-12-24
  • 2021-08-13
  • 2022-12-23
  • 2021-11-09
猜你喜欢
  • 2021-11-09
  • 2021-09-17
  • 2021-07-21
  • 2021-10-10
  • 2022-12-23
相关资源
相似解决方案