标签:math str targe generate efi eth ref public string
import java.util.Scanner; public class Main { public static int n; public static int[][] map = new int[110][120]; public static int[][] sum = new int[110][120]; public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); n = cin.nextInt(); for(int i = 0; i < n; i++) { for(int j = 0; j <= i; j++) { map[i][j] = cin.nextInt(); // System.out.println(sum[i][j]); } } System.out.println(get(0,0)); } public static int get(int i, int j) { if(sum[i][j] != 0) { //判断之前是否访问过,避免重复搜索而超时 return sum[i][j]; } if(i == n - 1) { return sum[i][j] = map[i][j]; } return sum[i][j] = Math.max( get(i+1,j), get(i+1,j+1)) + map[i][j]; } }
标签:math str targe generate efi eth ref public string
原文地址:https://www.cnblogs.com/zhumengdexiaobai/p/10367523.html