/*
简单DP:分成奇偶两种状况考虑
奇数情况:每个面的光线等于上次的本平面以上的点的反射
偶数情况:每个面的光线等于上次的本平面以下的点的反射
*/
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include <stdio.h>
2 #include <string.h>
3
4 long long F[ 61 ][ 4 ];
5
6 int main()
7 {
8 int i,j,k,n;
9 memset( F, 0L, sizeof( F ) );
10 F[ 0 ][ 0 ] = 1L;
11
12 for ( i = 1 ; i <= 60 ; ++ i )
13 for ( j = 0 ; j <= 3 ; ++ j )
14 if ( i%2 ) {
15 for ( k = 0 ; k < j ; ++ k )
16 F[ i ][ j ] += F[ i-1 ][ k ];
17 }else {
18 for ( k = j+1 ; k <= 3 ; ++ k )
19 F[ i ][ j ] += F[ i-1 ][ k ];
20 }
21 while ( scanf("%d",&n) != EOF ) {
22 long long sum = 0;
23 for ( i = 0 ; i < 3 ; ++ i )
24 sum += F[ n ][ i+n%2 ];
25 printf("%lld\n",sum);
26 }
27 return 0;
28 }