HDU 2045 is not an easy series (3)-Lele's RPG puzzle

Source: Internet
Author: User



Problem description: Lele, the super idol of "the killer of the AC female", suddenly played Deep recently, which can lead to a lot of "Cole" (Lele fans, "Cola "), after many probing, a senior Cole finally learned the cause. It turns out that Lele has recently studied the famous RPG puzzle:

There are n squares arranged in a row, and each grid is painted in red, pink, and green, it is required that any adjacent square cannot be of the same color, and the first and last two cells are also different colors. evaluate all the methods that meet the requirements.

The above is the famous RPG puzzle.

If you are Cole, I think you will definitely try your best to help Lele solve this problem. If not, you will not stand by if you look at the faces of many beautiful Cole women who are not ready to live?

 


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


Output for each test instance, please output all the methods that meet the requirements, each instance output occupies a line.
 


Sample Input
12
Set the color number of N grids to f [N]. It is easy to calculate f [1], F [2], F [3]. assume that the color of the n-1 lattice is different from that of the 1st lattice, the color of the n-1 lattice can only be one color, that is, the number of F [n-1. Assuming the same, you can take two colors, both of which are f [N-2]. Then f [N] = f [n-1] + 2 * f [N-2].
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <set>#include <stack>#include <cctype>#include <algorithm>#define lson o<<1, l, m#define rson o<<1|1, m+1, rusing namespace std;typedef long long LL;const int maxn = 500050;const int mod = 99999997;const int MAX = 0x3f3f3f3f;int t, a, b;LL f[100];int main(){    f[1] = 3;    f[2] = 6;    f[3] = 6;    for(int i = 4; i <= 50; i++) f[i] = f[i-1] + 2*f[i-2];    while(~scanf("%d", &b)) {        printf("%I64d\n", f[b]);    }    return 0;}

Zookeeper

HDU 2045 is not an easy series (3)-Lele's RPG puzzle

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.