Problem:
Recursion, this kind of problem should be carefully drawn out its law will be clear, light by imagination is difficult to calculate the right.
For insurance double, int should also be able to install.
Dominoes Shop SquaresTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 34969 Accepted Submission (s): 16979
Problem description in a rectangular square of 2xn, fill the squares with a 1x2 domino, enter N, and output the total number of paving schemes.
For example, when n=3, for 2x3 squares, the Domino placement scheme has three kinds, such as:
Input data consists of multiple lines, each containing an integer n, indicating that the size of the rectangular square of the test instance is 2xn (0<n<=50).
Output for each test instance, export the total number of tiling schemes, one row for each instance.
Sample Input
132
Sample Output
132
Code:
Import java.util.*;p ublic class main{public static void Main (string[] args) {Scanner cin=new Scanner (system.in);d ouble[] A=new double[55];a[1]=1;a[2]=2;for (int i=3;i<51;i++) A[i]=a[i-1]+a[i-2];while (Cin.hasnext ()) {int N=cin.nextInt ( ); System.out.printf ("%.0f\r\n", A[n]);}}}
HDU Domino Shop (Java)