10. The rectangular footprint
topic
We can use 2 small rectangle 1 of sideways or vertically to cover a larger rectangle. Will the use of n 2 small rectangle 1 coverage without overlap a large rectangle 2 * n, a total of how many ways?
For n = 3 for example, 2 * 3 tile is covered There are three methods:
Thinking
Or Fibonacci number, 2 * 2 matrix, there are two filling methods, three methods is a method that is 3 * 2, n-2 * a n-1 and n-2 and the
Code
public static int JumpFloor(int target) {
if (target <= 0) {
return 0;
}
if(target==1)
{
return 1;
}
if (target==2)
{
return 2;
}
int f[] = new int[target + 1];
f[1] = 1;
f[2] = 2;
for (int i = 3; i <= target; i++) {
f[i] = f[i - 1] + f[i - 2];
}
return f[target];
}