HDU4283:You Are the One(区间DP)
来源:互联网 发布:mac wine下载安装 编辑:程序博客网 时间:2024/05/16 17:10
转自:http://blog.csdn.net/libin56842/article/details/9722077
自己还是不会。。
关键在于找子问题和决策,,,
他这里很详细。。
决策就分。。。 第一个,第k个,(k为1~n),,这样的话就是枚举了。。‘(一般都要这种枚举的过程)
#include<iostream>#include<bits/stdc++.h>using namespace std;#define sf scanf#define pf printf#define mem(a,b) memset(a,b,sizeof(a));#define inf 0x3f3f3f3f#define INF 1e9;#define LL long longconst int maxn=105;int a[maxn];int dp[maxn][maxn];int sum[maxn];int main(){ int T; sf("%d",&T); while(T--){ int n; sf("%d",&n); mem(sum,0); for(int i=1;i<=n;++i){ sf("%d",&a[i]); sum[i]=sum[i-1]+a[i]; }mem(dp,0); for(int i=1;i<=n;++i){ for(int j=i+1;j<=n;++j){ dp[i][j]=INF; } } for(int s=1;s<n;++s){ for(int i=1;i+s<=n;++i){ int j=i+s; for(int k=1;k<=s+1;++k){//要是s+1 , s+1 就是区间的长度 dp[i][j]=min(dp[i][j],dp[i+1][i+k-1]+dp[i+k][j]+k*(sum[j]-sum[i+k-1])+(k-1)*a[i]); } } } pf("%d\n",dp[1][n]); }}
0 0
- hdu4283 You Are the One(区间DP)
- HDU4283:You Are the One(区间DP)
- hdu4283---You Are the One(区间dp)
- hdu4283 you are the one 区间DP
- HDU4283:You Are the One(区间DP)
- HDU4283 You Are the One 区间DP
- hdu4283 You Are the One(区间DP)
- hdu4283 You Are the One 区间DP
- HDU4283:You Are the One(区间DP)
- HDU4283 You Are the One 有点难的区间DP
- HDU4283——You Are the One(区间DP)
- hdu4283 You Are the One(区间DP)
- hdu4283 You Are the One(区间dp,思考)
- HDU4283 You Are the One(区间dp)
- hdu4283——You Are the One(区间dp)
- HDU4283——You Are the One(区间dp)
- HDU4283——You Are the One (区间DP)
- HDU4283 You Are the One (DP)
- npm和bower的区别
- 2017年第十届华中地区大学生数学建模邀请赛经典赛C题 雄安新区的设立对北京的影响研究
- poj3090(欧拉函数)
- 字符串的基本操作
- Eclipse进行debug启动Tomcat时,由于启动项过多45秒超时解决方式
- HDU4283:You Are the One(区间DP)
- jdbc
- c++11 producer and customer design
- HDU
- ubuntu16.04安装opencv3.2
- 数论
- LintCode 53 翻转字符串
- ES6学习及参考资料
- VR develop resource