和2547那道差不多,反正就是找规律,找出来后就好搞
#include<stdio.h>
int main()
{
int a[20], i, j, sum;
a[1] = 1;
a[2] = 5;
for (i = 3; i <= 19; i++)
{
sum = i % 2 ? 2 : 3;
for (j = 1; j < i; j++)
if (j == 1)
sum += a[i - 1];
else if (j == 2)
sum += 4 * a[i - 2];
else
sum += (j % 2 ? 2 : 3) * a[i - j];
a[i] = sum;
}
int n;
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
scanf("%d", &j);
printf("%d %d\n", i, a[j]);
}
return 0;
}