标签:分数 length nbsp ons div exp real note 5*
1 public int maxCoins(int[] nums) { 2 int len = nums.length; 3 int[]num = new int[len+2]; 4 int[][]dp = new int[len+2][len+2]; 5 for(int i = 0;i<=len+1;i++) 6 if(i==0||i==len+1)num[i] = 1; 7 else num[i] = nums[i-1]; 8 int j = 0,temp = 0; 9 for(int k = 1;k<=len;k++) { 10 for(int i = 1;i<=len-k+1;i++) { 11 j = i+k-1; 12 for(int x = i;x<=j;x++) { 13 temp = dp[i][x-1]+num[i-1]*num[x]*num[j+1]+dp[x+1][j]; 14 dp[i][j] = dp[i][j]>temp?dp[i][j]:temp; 15 } 16 } 17 } 18 return dp[1][len]; 19 }
标签:分数 length nbsp ons div exp real note 5*
原文地址:https://www.cnblogs.com/messi2017/p/9900022.html