Package org.bluebridge.topics;
* * 39th step
Xiao Ming just finished watching the film "39th Step", when he left the cinema, he counted the number of steps in front of the auditorium, happens to be level 39!
Standing in front of the steps, he suddenly thought of a question:
If I could only step 1 or 2 steps each. Take the left foot first, then turn left and right, and the
last step is to take the right-hand foot, which means you have to go even step.
So, how many different methods are there when you finish the 39 steps?
Please use the advantage of the computer to help xiaoming find the answer.
* */Public
class Number_39steps {public
static void Main (string[] args) {
int[][] step = new int[39][ 2];//first Dimension is a 39-storey ladder, the second dimension is left
/right foot//For the first step, there are 1 ways to reach the left foot, 0 kinds (because the title requires first to step left foot)
step[0][0] = 1;
STEP[0][1] = 0;
For the second ladder, there are 1 ways to get to the left foot, because each step can only reach 1 or 2 steps, the right foot has 1 kinds of
step[1][0] = 1;
STEP[1][1] = 1;
for (int i = 2; i < i++) {
step[i][1] = step[i-2][0] + step[i-1][0];
Step[i][0] = step[i-2][1] + step[i-1][1];
}
System.out.println (step[38][1]);
}