Ox's EOF Beef skewer
http://acm.hdu.edu.cn/showproblem.php?pid=2047
Time limit:2000/1000 MS (java/others)
Memory limit:65536/32768 K (java/others) Problem Description
This year's ACM summer Team A total of 18 people, divided into 6 teams. One of the teams, called EOF, consists of a class of 04 cows, XC, and 05 coy. In the common training life, we have established a deep friendship, a cow is ready to do something to commemorate this passion burning years, think about it, a cow from the home a fine beef jerky, ready to carve a length of n by "E" "O" "F" A string of three characters (which can have only one or two characters, but absolutely no other characters), while an ox prohibits the presence of O in the string, he believes that "OO" looks like an angry eye and does not work well. You, the NEW acmer,eof admirer, can help a cow. How many different strings are there to meet the requirements? PS: An ox also has a little secret, is ready to the carved with EOF beef jerky, as a mysterious gift to hang electric 50 anniversary celebration, can imagine, when the headmaster took this piece of beef dry time how happy! Here, please allow me on behalf of Hangzhou Electric Acmer to Aniu Express thanks! Thanks again!
Input
The input data contains multiple test instances, one row for each test instance, and an integer n consisting of (0<n<40).
Output
For each test instance, please output all the required coating methods, and each instance's output occupies one row.
Sample Input
12
Sample Output
38
Thought See http://blog.csdn.net/lostaway/article/details/5742571
Complete code:
/*0ms,204kb*/
#include <cstdio>
long long f[40];
int main ()
{
int i, n;
F[1] = 3L, f[2] = 8L;
for (i = 3; i < ++i) F[i] = (F[i-1] + f[i-2]) << 1;
while (~SCANF ("%d", &n))
printf ("%i64d\n", F[n));
return 0;
}
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45513.htm