当前位置:网站首页>dp-能量项链
dp-能量项链
2022-04-23 14:08:00 【抠脚老騷】
能量项链
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
//const int inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
const int maxn = 1e4 + 10;
const int N = 6e6 + 100;
int dp[maxn][maxn];
int a[maxn];
int v[maxn];
void solve() {
int n;
cin>>n;
for (int i = 1; i <=n; ++i) {
cin>>a[i];
a[n+i]=a[i];
}
for(int len=3;len<=n+1;len++){
for(int l=1;l<=2*n-len+1;l++){
int r=l+len-1;
for(int k=l+1;k<r;k++){
dp[l][r]=max(dp[l][r],dp[l][k]+dp[k][r]+a[l]*a[k]*a[r]);
}
}
}
int res=0;
for(int i=1;i<=n;i++){
res=max(res,dp[i][i+n]);
}
cout<<res;
}
signed main() {
//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
// cin >> _;
while (_--) {
solve();//cout<<"\n";
}
return 0;
}
//12341
//14321
//
版权声明
本文为[抠脚老騷]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45436102/article/details/123975536
边栏推荐
- Storage path of mod subscribed by starbound Creative Workshop at Star boundary
- JSP学习2
- PySide2
- win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
- leetcode--380. O (1) time insertion, deletion and acquisition of random elements
- Subscription number development of wechat applet (message push)
- RecyclerView高级使用(一)-侧滑删除的简单实现
- 关于NodeJS中JSON5的相关配置和使用
- Windos中安装labellmg教程
- 封装logging模块
猜你喜欢
随机推荐
Windos中安装labellmg教程
查询2013年到2021年的数据,只查询到2020的数据,遇到了这个问题所进行的解决办法
使用开源调研工具Prophet是一种什么体验?
Operation instructions of star boundary text automatic translator
Request module
关于NodeJS中JSON5的相关配置和使用
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
Recyclerview advanced use (II) - simple implementation of vertical drag and drop sorting
jsp学习3
mysql 5.1升级到5.66
政务云迁移实践 北明数科使用HyperMotion云迁移产品为某政府单位实施上云迁移项目,15天内完成近百套主机迁移
Prediction of tomorrow's trading limit of Low Frequency Quantization
Wechat applet positioning and ranging through low-power Bluetooth device (2)
多云数据流转?云上容灾?年前最后的价值内容分享
正则表达式
On the problem of cliff growth of loss function in the process of training
JDBC详解
贷款市场报价利率(LPR)与贷款基准利率介绍
关于训练过程中损失函数出现断崖式增长的问题
RecyclerView细节研究-RecyclerView点击错位问题的探讨与修复








