找規律
dp[i]=d[i-1]+4*dp[i-2]+2*(dp[i-3]+dp[i-5],,,,,,,,,)+3*(dp[i-4]+dp[i-6]+,,,,,,,);
[cpp]
#include<stdio.h>
int dp[1001];
int main()
{
dp[0]=1;dp[1]=1;dp[2]=5;
int i,j,t,op,n;
for(i=3;i<=1000;i++)
{
dp[i]=dp[i-1]+4*dp[i-2];
for(j=3;j<=i;j++)
{
if(j%2==1)
dp[i]+=2*dp[i-j];
else dp[i]+=3*dp[i-j];
}
}
scanf("%d",&t);
op=1;
while(t--)
{
scanf("%d",&n);
printf("%d %d\n",op++,dp[n]);
}
return 0;
}
#include<stdio.h>
int dp[1001];
int main()
{
dp[0]=1;dp[1]=1;dp[2]=5;
int i,j,t,op,n;
for(i=3;i<=1000;i++)
{
dp[i]=dp[i-1]+4*dp[i-2];
for(j=3;j<=i;j++)
{
if(j%2==1)
dp[i]+=2*dp[i-j];
else dp[i]+=3*dp[i-j];
}
}
scanf("%d",&t);
op=1;
while(t--)
{
scanf("%d",&n);
printf("%d %d\n",op++,dp[n]);
}
return 0;
}