Not easy series of (3)--lele RPG puzzles
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 34689 Accepted Submission (s): 13913
Problem description called "AC female killer" Super Idol Lele recently suddenly played a deep, this can be nasty a lot of "Cole" (Lele fans, that is, "Cola"), after the multi-snooping, a veteran Cole finally know the reason, the original, 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?
Input data contains multiple test instances, one row per test instance, and an integer n, (0<n<=50).
Output for each test instance, export all of the required coating methods, one row for each instance output.
Sample Input
12
Sample Output
36
Authorlcy
problem! Difficult in the first few items are not initialized to!
Ideas:
n a lattice that conforms to the coloring of the title (known as legal) corresponds to a map f so that f (n) is the evaluated value. Then the next analysis, Dangtu
in the nth lattice, when f (n) is required, the n-1 lattice is subject to the same constraints as the first lattice. So the next question is, for the first
n-1 a lattice in two cases: assuming that it is different from the first lattice color, then that is to say, the former n-1 lattice is a valid coating can be written as F (n-1),
The last lattice is coated with only one coating method. The second type of n-1 lattice is the same as the first one, then the former n-1 is not legal, and at this time the n-2 lattice must and
The first difference, then at this time before the n-2 lattice must be legal, and the nth lattice 2 kinds of coating method. So the contribution to F (n) is F (n-2), then
f (n) derives from the sum of the first two conditions, by the addition principle. F (n) =f (n-1) +f (n-2) *2;n "=4";
AC:
#include <iostream>using namespace Std;int main () {int m;double ls[51]={3,6,6}; for (int i=3;i<=50;i++) ls[i]=ls[i-1]+ls[i-2]*2;while (cin>>m) printf ("%.0lf\n", Ls[m-1]); return 0;}
Hangzhou Electric HDU ACM 2045 Not Easy series of (3)--lele RPG puzzles