当前位置:网站首页>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
边栏推荐
猜你喜欢
Nifi 快速安装及文件同步操作
Indoor and outdoor map switching (indoor three-point positioning based on ibeacons)
RobotFramework 之 项目框架
Visio installation error 1:1935 2: {XXXXXXXX
Postman的安装使用及填坑心得
关于云容灾,你需要知道这些
基於CM管理的CDH集群集成Phoenix
修改ddt生成的测试用例名称
Wechat applet initializes Bluetooth, searches nearby Bluetooth devices and connects designated Bluetooth (I)
Jmeter安装教程以及我遇到的问题的解决办法
随机推荐
HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
MySQL数据库讲解(十)
Some good articles on pthread multithreading
封装logging模块
Can I compile the header file and source file of the template separately
MySQL数据库讲解(七)
容灾有疑问?点这里
PySide2
在MAC上安装mysql
Oracle-数据泵使用
服务器日志分析工具(识别,提取,合并,统计异常信息)
正则表达式
About the configuration and use of json5 in nodejs
JDBC详解
How QT designer adds resource files
win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
Homebrew是什么?以及使用
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
redis数据库讲解(四)主从复制、哨兵、Cluster群集
更改plsql工具栏的图标大小