To prove safety offer Q8.
Title Description
A frog can jump on a Class 1 level, you can also hop on level 2. The frog jumped seeking a total of n grade level how many jumps (the order of different calculation different results).
Problem-solving ideas
Jumps to this question, as long as only one of the first-order or second order.
- If the two jumps, the first-order or second-order, it is assumed that the first hop is a first order, the remaining steps are the n-1, F is the jumps (n-1);
- The first hop is assumed that the second order, the remaining n-2 th is a step, jump method is F (n-2)
- The total jump method can be derived as: f (n) = f (n-1) + f (n-2)
- Then the actual situation can be obtained by: a first order only when f (1) = 1, when only two bands may have f (2) = 2
my answer
1 |
大专栏 【面试题8ine">public class { |