不容易系列之(3)—— LELE的RPG难题

来源:互联网 发布:数据分析师加班厉害吗 编辑:程序博客网 时间:2024/06/01 15:02

不容易系列之(3)—— LELE的RPG难题

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 52704    Accepted Submission(s): 21175


Problem Description
人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即"可乐"),经过多方打探,某资深Cole终于知道了原因,原来,LELE最近研究起了著名的RPG难题:

有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法.

以上就是著名的RPG难题.

如果你是Cole,我想你一定会想尽办法帮助LELE解决这个问题的;如果不是,看在众多漂亮的痛不欲生的Cole女的面子上,你也不会袖手旁观吧?

 

Input
输入数据包含多个测试实例,每个测试实例占一行,由一个整数N组成,(0<n<=50)。
 

Output
对于每个测试实例,请输出全部的满足要求的涂法,每个实例的输出占一行。
 

Sample Input
12
 

Sample Output
36
 

Author
lcy
 

Source
递推求解专题练习(For Beginner)
 

Recommend
lcy   |   We have carefully selected several similar problems for you:  2046 2050 2047 2049 2048 
#include<iostream>#include<cstdlib>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<cstdlib>#include <set>#include<algorithm>#include <limits.h>#include <ctype.h>#include <map>#include <stack>#include <vector>#include <sstream>#include <string.h>typedef long long LL;using namespace std;const int N = 101;LL data[N];#define PI 3.1415926typedef __int64 LL;using namespace std;void fun(){    data[1] = 3;    data[2] = 6;    data[3] = 6;    for(int i = 4; i < N; i++){        data[i] = data[i - 1] + 2 * data[i - 2];    }}int main() {    //freopen("in.txt","r",stdin);    //freopen("out.txt","w",stdout);    //memset(data, 1, sizeof(data)); //初始化为1 为没预定的状态    fun();    int n;    while(scanf("%d", &n) != EOF){        cout << data[n] << endl;    }    return 0;}

0 0
原创粉丝点击