HDU 2045 不容易系列之(3)—— LELE的RPG難題

來源:互聯網
上載者:User
不容易系列之(3)—— LELE的RPG難題

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

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
import java.math.BigInteger;import java.util.*;public class Main {    public static void main(String[] args) {        Scanner sc=new Scanner(System.in);        while(sc.hasNextInt()){            int m=sc.nextInt();            BigInteger a[]=new BigInteger[50];            a[0]=BigInteger.valueOf(3);            a[1]=BigInteger.valueOf(6);            a[2]=BigInteger.valueOf(6);            if(m==1) System.out.println("3");            else if(m==2)System.out.println("6");            else if(m==3) System.out.println("6");            else{                                for(int i=3;i<m;i++){                    a[i]=a[i-1].add(BigInteger.valueOf(2).multiply(a[i-2]));                }                System.out.println(a[m-1]);            }        }    }}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.