HDU 4283 You Are the One(区间dp、状态转移)
来源:互联网 发布:java 多泛型 编辑:程序博客网 时间:2024/06/14 00:25
题目链接;
HDU 4283 You Are the One
题意:
【非诚勿扰?】
有
数据范围:
分析:
区间
其主要难点也许在于如何确定状态转移,更具体的说,就是确定循环枚举的第三层的
但是这道题,我们首先可以把小黑屋看成一个栈,如果我们枚举区间第
我们可以枚举第
对于子区间
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <climits>#include <cmath>#include <ctime>#include <cassert>#define IOS ios_base::sync_with_stdio(0); cin.tie(0);using namespace std;typedef long long ll;const int MAX_N = 110;const int inf = 0x7fffffff;int T, n, cases = 0;ll data[MAX_N], sum[MAX_N], dp[MAX_N][MAX_N];int main(){ scanf("%d", &T); while (T--) { scanf("%d", &n); sum[0] = 0; for (int i = 1; i <= n; ++i) { scanf("%lld", &data[i]); sum[i] = sum[i - 1] + data[i]; } for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { if (i < j) dp[i][j] = inf; else dp[i][j] = 0; } } for (int i = n; i >= 1; --i) { for (int j = i + 1; j <= n; ++j) { for (int k = 1; k <= j - i + 1; ++k) { dp[i][j] = min(dp[i][j], data[i] * (k - 1) + dp[i + 1][i + k - 1] + dp[i + k][j] + k * (sum[j] - sum[i + k - 1])); } } } printf("Case #%d: %lld\n", ++cases, dp[1][n]); } return 0;}
0 0
- HDU 4283 You Are the One(区间dp、状态转移)
- hdu 4283 You Are the One(区间DP)题目转换难,状态难,。。。
- HDU 4283 You Are the One 区间dp
- hdu 4283 You Are the One 区间dp
- HDU 4283 You Are the One(区间DP)
- hdu 4283 You Are the One(区间dp)
- HDU --4283--You Are the One--区间DP
- hdu 4283 You Are the One(区间DP)
- HDU 4283 You Are the One(区间dp)
- HDU 4283 You Are the One 区间dp
- HDU 4283 You Are the One (区间DP)
- HDU 4283 You Are the One(区间dp)
- hdu 4283 You Are the One(区间dp)
- Hdu 4283 You Are the One(区间dp)
- HDU 4283 You are the one(区间DP)
- HDU 4283 You Are the One(区间DP)
- HDU 4283 You Are the One (区间dp)
- HDU 4283 You Are the One(区间dp)
- opencv笔记
- Java调用Matlab
- Jieba中文分词说明
- 使用apicloud实现注册功能和短信验证功能
- java动态代理
- HDU 4283 You Are the One(区间dp、状态转移)
- java SPI 与cooma(dubbo 微容器改良品)--1
- org-trello的常用命令
- 2016/07/24
- boost::function与回调函数
- 浅析C++const
- 有序查找
- web开发之路
- 网站运营如何寻找“种子用户”?