5-3记忆型递归

2021-04-19 17:57:13 浏览数 (1)

代码语言:javascript复制
/**
 * @Author CaesarChang张旭
 * @Date 2021/2/18  12:06 下午
 * @Version 1.0
 */
public class Main {
    
    static int n;
    static int m;
    //记忆化递归
    static int [][] rec;  
    public static void main(String[] args) {

       Scanner scanner=new Scanner(System.in);

        n=scanner.nextInt();
        m=scanner.nextInt();

        int[][] arr = new int[n 1][m 1];
        rec = new int[n   1][m   1];

        System.out.println(dp(1,1));;

    }

    //记忆化递归一定要有返回值
    private static int dp(int curX, int curY) {
        //越界
        if(curX>n||curY>m){
            return 0;
        }
        
        //满足条件
        if (check(curX, curY

0 人点赞