Not easy series of (3)--lele RPG puzzlesTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 31681 Accepted Submission (s): 12671
problem Descriptioncalled "AC female killer" Super Idol Lele recently suddenly played a deep, this can be nasty many "Cole" (Lele fans, that is, "Cola"), after a lot of snooping, a veteran Cole finally know the reason, originally, Lele recently studied the famous RPG puzzle:
There are rows of n squares, with red (red), powder (Pink), Green (green) Three colors each lattice, each color, requires that any adjacent squares can not be the same color, and the first and the first two squares also different colors. All the requirements of the coating method.
These are the famous RPG puzzles.
If you are Cole, I think you will be able to help Lele solve the problem, if not, look at the many beautiful pain of the Cole Girl's face, you will not stand by?
InputThe input data contains multiple test instances, one row per test instance, and an integer n, (0<n<=50).
Outputfor each test instance, output all of the required coating methods, one row for each instance output.
Sample Input
12
Sample Output
$Problem Solving Ideas : If there are n squares, when the nth squares are filled, there are two cases: 1. If you have already filled in the front n-1 a color, there is f (n-1) case, at this time the first n-1 with a color must be different, so nth only one choice. 2. If you fill in the front n-2, there are f (n-2) case, the n-1 space color is the same as the first color, the last nth squares can fill two colors, so it is 2*f (n-2); Fully available: f (n) = f (n-1) + 2*f (n-2), n>=4.
Source:
#include <stdio.h> #include <stdlib.h>int main () {int i,n; Long Long a[51]={0,3,6,6}; for (i=4;i<51;i++) a[i]=a[i-1]+a[i-2]*2; while (scanf ("%d", &n)!=eof) {printf ("%i64d\n", A[n]); } system ("Pause"); return 0; }
Not easy series of (3)--lele RPG puzzles