#include <stdio.h>
int count;
/*one_count表示当前使用的1的个数,zero_count表示当前使用恶的0的个数,now_count表示前两个的和,all表示可以使用的所有0,1的个数*/
void recursion(int one_count, int zero_count, int now_count, int all)
{
/*保证条件满足,否则跳出*/
if (now_count > all - 1 || one_count < zero_count || one_count > all/2 || zero_count > all/2)
{
return;
}
/*找到一个结果,count++*/
if (now_count == all - 1 && one_count >= zero_count)
{
count++;
}
recursion(one_count+1, zero_count, now_count+1, all);
recursion(one_count, zero_count+1, now_count+1, all);
}
int count_entry(all)
{
int i, zero_count = 0, one_count = 0;
recursion(one_count, zero_count, 0, all);
}
int main(int argc, char *argv[])
{
int T, all, i;
scanf("%d", &T);
for (i=0 ; i<T ; i++)
{
scanf("%d", &all);
all *= 2;
count = 0;
count_entry(all);
printf("%d\n", count);
}
}
|