直接上代码:

package com.shopping.test;

public class test {

    public static long getStepNumber(int n)  {
        if (0 > n) {
            return 0;
        }
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        if (n > 2) {
            return getStepNumber(n - 1) + getStepNumber(n - 2);
        }
        return 0;
    }
    public static void main(String[] args) {
        System.out.println(getStepNumber(20));
    }
}

动态规划

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-08-21
  • 2021-12-01
  • 2021-10-22
  • 2022-12-23
  • 2022-01-31
猜你喜欢
  • 2021-05-28
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
相关资源
相似解决方案