zoukankan      html  css  js  c++  java
  • HDOJ_ACM_不容易系列之(3)—— LELE的RPG难题

    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
     
    Code
    View Code
    Key Points
    for f(n) n>3, there are two conditions.

     
    this is f(n-1), because this condition is same as f(n-1)

    this is 2*f(n-2), because the if the last second color is same to the first one, the last third color can't be same to the first one. Consequently, it's f(n-2), and you will find the the last one color have two cases, so, it's 2*f(n-2).

     
  • 相关阅读:
    eventkeyboardmouse
    代理 IP
    网关 192.168.2.1 114.114.114.114 dns查询
    http ssl
    SSDP 抓包
    抓包登录信息提交
    危险的input 微博的过去
    firstChild.nodeValue
    浏览器控制台
    haproxy 中的http请求和https请求
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2763744.html
Copyright © 2011-2022 走看看