HDU 2045 Not Easy Series (3)--lele RPG puzzle

Source: Internet
Author: User

Ideas:

1. If the color of the former n-1 is eligible, then there are only 1 ways to join one because of the difference in the first and last, s[n] = s[n-1]

2. If a string consisting of a former n-1 is not met, then it is lawful to join one. That is, because the end of the same caused by the illegal, then the string of the former n-2 is bound to be legal. At this point there are 2 ways to add the nth bit. ie s[n] = 2*s[n-2]

So the AC code:

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:24PX;" > #include <stdio.h>int main () {    int n,i;    __int64 a[55];    a[1]=3;    a[2]=6;    a[3]=6;    for (i=4;i<=50;i++)        a[i]=a[i-1]+2*a[i-2];    while (scanf ("%d", &n)!=eof)    {        printf ("%i64d\n", A[n]);    }    return 0;} </span>

HDU 2045 Not Easy Series (3)--lele RPG puzzle

Related Article

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.