标签:info blank names const https class include http c++
Code:
1 #include <bits/stdc++.h> 2 # define LL long long 3 using namespace std; 4 5 const int maxn=100+10; 6 int N; 7 int val[maxn]; 8 int dp[maxn][maxn]; 9 10 int pre(int i){ 11 return i==1?N:i-1; 12 } 13 14 int next(int i){ 15 return i==N?1:i+1; 16 } 17 18 int dfs(int left, int right){ 19 if(dp[left][right]!=-1) return dp[left][right]; 20 21 int res=0; 22 for(int i=left;i!=right;i=next(i)){ 23 int tmp=val[left]*val[next(i)]*val[next(right)]+dfs(left,i)+dfs(next(i),right); 24 res=max(res,tmp); 25 } 26 return dp[left][right]=res; 27 } 28 29 int main(){ 30 memset(dp,-1,sizeof(dp)); 31 scanf("%d", &N); 32 for(int i=1;i<=N;++i){ 33 scanf("%d", val+i); 34 } 35 int res=0; 36 for(int i=1;i<=N;++i){ 37 res=max(res,dfs(i,pre(i))); 38 } 39 printf("%d", res); 40 }
标签:info blank names const https class include http c++
原文地址:https://www.cnblogs.com/FEIIEF/p/12248576.html