#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int check(char number[100])
{
int i;
int count=0;
for(i=0;number[i]!='\0';i++)
{
if(number[i]=='1')count++;
}
return count;
}
void main()
{
int T,n,i,count,t;
bool finding;
char number[100];
while(scanf("%d",&T)!=EOF)
{
for(t=1;t<=T;t++)
{
count=0;
finding=true;
scanf("%d",&n); if(n<1||n>20)continue;
i=1;
itoa(i,number,2);
if(strlen(number)==n)finding=false;
for(i=1;strlen(number)==n||finding;i++)
{
if(strlen(number)==n)finding=false;
if(!finding)count+=check(number);
itoa(i,number,2);
}
if(n==1)count=1;
printf("%d\n",count);
}
}
}
HDU - 2502
最新推荐文章于 2021-04-29 22:00:49 发布