当前位置:网站首页>DP energy Necklace
DP energy Necklace
2022-04-23 14:13:00 【Stingy old Sao】
Energy necklace
#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
//
版权声明
本文为[Stingy old Sao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231407093980.html
边栏推荐
- 帆软中使用if else 进行判断-使用标题条件进行判断
- Subscription number development of wechat applet (message push)
- Essential difference between restful WebService and gSOAP webservice
- Promtail + Loki + Grafana 日志监控系统搭建
- mysql查询库大小
- DDT+Excel进行接口测试
- std::map 和 std::vector 内存释放
- Wechat applet initializes Bluetooth, searches nearby Bluetooth devices and connects designated Bluetooth (I)
- redis数据库讲解(三)redis数据类型
- JDBC details
猜你喜欢
查询2013年到2021年的数据,只查询到2020的数据,遇到了这个问题所进行的解决办法
win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
Detailed tutorial on the use of smoke sensor (mq-2) (based on raspberry pie 3B +)
MySQL数据库讲解(七)
Logback logger and root
VMware 15pro mounts the hard disk of the real computer in the deepin system
在Clion中给主函数传入外部参数
DDT+Excel进行接口测试
MySQL数据库讲解(八)
Installation and use of postman pit
随机推荐
JDBC详解
Detailed tutorial on the use of smoke sensor (mq-2) (based on raspberry pie 3B +)
利用json-server在本地创建服务器请求
Installation and use of postman pit
Pycharm连接远程服务器并实现远程调试
线程间控制之CountDownLatch和CyclicBarrier使用介绍
Redis数据库讲解(一)
在Clion中给主函数传入外部参数
Easyexcel读取excel表地理位置数据,按中文拼音排序
Operation instructions of star boundary automatic text translator (advanced version)
MYSQL 主从同步避坑版教程
VMWare安装64位XP中文教程
Oracle-数据泵使用
如何轻松做好一个项目
Research on recyclerview details - Discussion and repair of recyclerview click dislocation
教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%
Subscription number development of wechat applet (message push)
Wechat applet positioning and ranging through low-power Bluetooth device (2)
squid代理
帆软中使用if else 进行判断-使用标题条件进行判断