HDU 2047 Ox's EOF Beef skewer (dp+ in the wrong row)

Source: Internet
Author: User

Ox's EOF beef skewerTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 29868 Accepted Submission (s): 14028

problem Descriptionthis year's ACM summer training Team A total of 18 people, divided into 6 teams. There is a team called EOF, consisting of 04 levels of ox, XC, and Level 05 coy. In the common training life, we have established a deep friendship, a cow ready to do something to commemorate the burning years of passion, think, a cow from home brought a fine beef jerky, ready to carve a length of n only by "E" "O" "F" Three characters of a string (can only one or two characters, but absolutely no other characters), the Ox also prohibits the appearance of o adjacent in the string, he thought, "OO" looks like angry eyes, the effect is not good.

You, NEW Acmer,eof's admirer, can you count the number of different strings that meet the requirements?

PS: Ox also has a small secret, is ready to put this engraved with EOF beef dry, as a mysterious gift for Hangzhou 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!
InputThe input data contains multiple test instances, one row per test instance, and an integer n, (0<n<40).

Outputfor each test instance, output all of the required coating methods, one row for each instance output.

Sample Input
12

Sample Output
38
 AuthorLCY SourceRecursive Solution topic exercise (for beginner)
The following:set the N-bit string, plus the last one is o the number of strings is a[n], the last one is not o the number of strings is b[n],
The total number of strings is x[n],
Then there are
X[n]=a[n]+b[n];
A[N]=B[N-1];
B[N]=2*X[N-1];
====>x[n]=2*x[n-1]+2*x[n-2]
AC Code: 
#include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> #include <cstring > #include <string> #include <cstdlib> #include <iomanip> #include <algorithm>typedef long Long ll;using namespace std; #define MAX 40int Main () {int n,i; LL A[40];while (cin>>n) {a[1]=3;a[2]=8;for (i=3;i<=n;i++) a[i]= (a[i-1]+a[i-2]) *2;cout<<a[n]<< Endl;}    return 0;}

HDU 2047 cow's EOF beef skewer (dp+)

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.