Not easy series (3)-Lele's RPG puzzle
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 23277 accepted submission (s): 9231
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
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]); } } }}