zoukankan      html  css  js  c++  java
  • 搜索打表大找规律 (hdu2045)

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

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


    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
    1 2
     
    Sample Output
    3 6
     
    Author
    lcy
     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 using namespace std;
     5 long long a[56];
     6 int co=0;
     7 int n;
     8 void dfs(int k)
     9 {
    10     if(k==(n+1))
    11     {
    12         if(a[1]!=a[n])
    13             co++;
    14         return;
    15     }
    16     for(int i=0;i<3;i++)
    17     {
    18         if(i!=a[k-1])
    19         {
    20             a[k]=i;
    21             dfs(k+1);
    22         }
    23     }
    24     return;
    25 }
    26 int main()
    27 {
    28     
    29     int i,j;
    30     a[1]=3,a[2]=6,a[3]=6;
    31     for(i=4;i<=52;i++)
    32         a[i]=a[i-2]*2+a[i-1];
    33     while(cin>>n)
    34     {
    35         cout<<a[n]<<endl;
    36         /*memset(a,0,sizeof(a));
    37         co=0;
    38         if(n==1)
    39         {
    40             cout<<3<<endl;
    41             continue;
    42         }
    43         for(i=0;i<3;i++)
    44         {
    45             a[1]=i;
    46             dfs(2);
    47         }
    48         cout<<co<<endl;*/
    49     }
    50 }
  • 相关阅读:
    jsf+ejb
    java CDI
    Android5.0新特性——阴影和剪裁(shadow)
    Android5.0新特性——图片和颜色(drawable)
    Android5.0新特性——全新的动画(animation)
    Android SDK Tools和Android SDK Platform-tools
    Android5.0新特性——Material Design简介
    emulator: ERROR: x86 emulation currently requires hardware acceleration!
    Android应用与系统安全防御
    JSON数据解析(转)
  • 原文地址:https://www.cnblogs.com/a1225234/p/5043636.html
Copyright © 2011-2022 走看看