Hdu2047.java Recurrence Problem

Source: Internet
Author: User

Ox's EOF Beef skewer

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 29530 Accepted Submission (s): 13853


Problem description This 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!

Input data contains multiple test instances, one row per test instance, and an integer n, (0<n<40).

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

Sample Input12

Sample OUTPUT3 8

Import java.util.*;
Class main{
public static void Main (String args[])
{Scanner cin=new Scanner (system.in);
while (Cin.hasnext ())
{int n=cin.nextint ();
SYSTEM.OUT.PRINTLN (sum (n));
}
}
public static long sum (int s)
{Long []a=new long [41];
a[1]=3;a[2]=8;
for (int i=3;i<41;i++)
a[i]=2* (A[i-1]+a[i-2]);
return A[s];
}
}
This topic is if the last one is O, the previous one can only be E or F, that is 2 times a[i-2]; If the last one is E or F then that is 2 times a[i-1];

Hdu2047.java Recurrence Problem

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.