Hdu2047 Niu's EOF beef string

Source: Internet
Author: User

Niu's EOF beef string
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 12267 Accepted Submission (s): 5769


Problem Description
This year's ACM summer training team has a total of 18 members, divided into 6 teams. There is an EOF team, which consists of class 04 COY, class 04 COY, and class 05 COY. In our common training life, we have established a profound friendship. What are you going to do to commemorate this passionate age, A Niu picked up a piece of beef jerky from his house, prepare a string of n characters consisting of only "E" "O" "F" (either one or two of them, but definitely cannot have other characters). At the same time, a Niu prohibits the occurrence of O adjacent conditions in the string. He believes that "OO" looks like angry eyes, and the effect is not good.

You, NEW ACMer, EOF fan, can you help Daniel calculate how many different types of strings meet the requirements?

PS: A Niu has another secret, that is, preparing to dedicate the EOF beef jerky as a mysterious gift to the anniversary celebration of hangdian. We can imagine how happy it was when the headmaster took over the beef jerky! Here, I would like to express my thanks to ACMer of hangdian!

Thanks again!
 

Input
The input data contains multiple test instances. Each test instance occupies one row and is composed of an integer of n (0 <n <40 ).
 

Output
For each test instance, please output all the methods that meet the requirements. The output of each instance occupies one line.
 

Sample Input
1
2
 

Sample Output
3
8

 

Another dp, I am the only water man to do this simple dp.

Haha it's not easy series (3)-the RPG puzzle of LELE is the same !!!

 

[Cpp]
# Include <stdio. h>
# Include <iostream>
Using namespace std;
# Include <algorithm>
_ Int64 same [51], dif [51];
Int main ()
{
Int I, n;
Same [1] = 1;
Dif [1] = 2;
For (I = 2; I <= 40; I ++)
{
Same [I] = dif [I-1]; // same [I] indicates that the end of an I length is o
Dif [I] = 2 * dif [I-1] + same [I-1] * 2; // dif [I] indicates that the end of an I length is not o
}
While (cin> n)
{
Printf ("% I64d \ n", dif [n] + same [n]);
}
Return 0;
}


 

Author: xiongheqiang

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.