当前位置:网站首页>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
边栏推荐
- Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
- win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
- pthread_ Why does self() repeat
- OpenStack命令操作
- Wechat applet obtains login user information, openid and access_ token
- JDBC详解
- 帆软分割求解:一段字符串,只取其中某个字符(所需要的字段)
- HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
- GFS分布式文件系统(理论)
- MySQL数据库讲解(七)
猜你喜欢
随机推荐
VMware installation 64 bit XP Chinese tutorial
关于云容灾,你需要知道这些
连接公司跳板机取别名
leetcode--380. O (1) time insertion, deletion and acquisition of random elements
jsp学习1
JDBC和servlet写CRUD的接口总结
ActiveMQ Basics
不同时间类型的执行计划计算
基於CM管理的CDH集群集成Phoenix
RobotFramework 之 项目框架
leetcode--977. Squares of a Sorted Array
Jmeter安装教程以及我遇到的问题的解决办法
Promtail + Loki + Grafana 日志监控系统搭建
帆软中根据分类进行汇总
如何快速批量创建文本文档?
Logging module
Wechat applet input hidden and inoperable settings
01-NIO基础之ByteBuffer和FileChannel
Kettle -- control parsing
使用开源调研工具Prophet是一种什么体验?