就是一道排列组合题,递归,前三项没什么好说的,4格子时要考虑第一格和第三格同色不同色两种情况,5格子时要考虑1和4格同色不同色,不同色时还要考虑1和3格子是否同色,推出递归式。
涂格子
涂格子

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   int t,i;
   long long  a[51];
   a[0]=0,a[1]=3,a[2]=6,a[3]=6;
   for(i=4;i<51;i++)
   {
       a[i]=a[i-1]+2*a[i-2];
   }
  while(scanf("%d",&t)!=EOF)
  {
      printf("%lld\n",a[t]);
  }

    return 0;
}

相关文章:

  • 2021-07-17
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-02
  • 2021-07-15
  • 2022-12-23
  • 2021-10-21
  • 2021-05-27
  • 2021-08-19
  • 2021-11-17
相关资源
相似解决方案