当前位置: 首页 > news >正文

代理网站平台网站排名分析

代理网站平台,网站排名分析,web开发不只是做网站,江苏昆山网站建设设有 N 堆石子排成一排,其编号为 1,2,3,…,N。 每堆石子有一定的质量,可以用一个整数来描述,现在要将这 N 堆石子合并成为一堆。 每次只能合并相邻的两堆,合并的代价为这两堆石子的质量之和,合并后与这两堆石子相邻的…

设有 N 堆石子排成一排,其编号为 1,2,3,…,N。

每堆石子有一定的质量,可以用一个整数来描述,现在要将这 N 堆石子合并成为一堆。

每次只能合并相邻的两堆,合并的代价为这两堆石子的质量之和,合并后与这两堆石子相邻的石子将和新堆相邻,合并时由于选择的顺序不同,合并的总代价也不相同。

例如有 44 堆石子分别为 1 3 5 2, 我们可以先合并 1、2堆,代价为 44,得到 4 5 2, 又合并 1、2堆,代价为 9,得到 9 2 ,再合并得到 11,总代价为 4+9+11=24;

如果第二步是先合并 2、3堆,则代价为 7,得到 4 7,最后一次合并代价为 11,总代价为 4+7+11=22

问题是:找出一种合理的方法,使总的代价最小,输出最小代价。

输入格式

第一行一个数 N 表示石子的堆数 N。

第二行 N 个数,表示每堆石子的质量(均不超过 1000)。

输出格式

输出一个整数,表示最小代价。

数据范围

1≤N≤300

输入样例:

4
1 3 5 2

输出样例:

22
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 300 + 5;
const int INF = 1e9;
int n;
int sum[N], dp[N][N];int main() {cin >> n;for (int i = 1; i <= n; i++) {scanf("%d", &sum[i]);sum[i] += sum[i - 1];}for (int len = 2; len <= n; len++) {for (int l = 1; l + len - 1 <= n; l++) {int r = len + l - 1;dp[l][r] = INF;for (int k = l; k < r; k++) {dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + sum[r] - sum[l - 1]);}}}cout << dp[1][n] << endl;return 0;
}

代码2

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 300 + 5;
const int INF = 1e9;
int n;
LL sum[N], dp[N][N];int main() {cin >> n;for (int i = 1; i <= n; i++) {scanf("%ld", &sum[i]);sum[i] += sum[i - 1];}for (int i = n; i >= 1; i--) {for (int j = i + 1; j <= n; j++) {dp[i][j] = INF;for (int k = i; k < j; k++) {dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum[j] - sum[i - 1]);}}}cout << dp[1][n] << endl;return 0;
}

 


文章转载自:
http://theism.hwbf.cn
http://porch.hwbf.cn
http://assumption.hwbf.cn
http://marchese.hwbf.cn
http://seraphic.hwbf.cn
http://astoundment.hwbf.cn
http://laocoon.hwbf.cn
http://neuroregulator.hwbf.cn
http://cryophysics.hwbf.cn
http://caginess.hwbf.cn
http://caricature.hwbf.cn
http://sanandaj.hwbf.cn
http://wearer.hwbf.cn
http://freshen.hwbf.cn
http://exarticulation.hwbf.cn
http://kernicterus.hwbf.cn
http://following.hwbf.cn
http://endarteritis.hwbf.cn
http://soloistic.hwbf.cn
http://basicity.hwbf.cn
http://dykey.hwbf.cn
http://nipping.hwbf.cn
http://enchylema.hwbf.cn
http://phonoreceptor.hwbf.cn
http://ethnologic.hwbf.cn
http://implantation.hwbf.cn
http://duopoly.hwbf.cn
http://duodenotomy.hwbf.cn
http://fundic.hwbf.cn
http://metaxa.hwbf.cn
http://spearfisherman.hwbf.cn
http://birdman.hwbf.cn
http://timepiece.hwbf.cn
http://heptateuch.hwbf.cn
http://nitride.hwbf.cn
http://shoot.hwbf.cn
http://pentyl.hwbf.cn
http://vesperal.hwbf.cn
http://curtain.hwbf.cn
http://matrilineal.hwbf.cn
http://presurgical.hwbf.cn
http://launder.hwbf.cn
http://sulfatase.hwbf.cn
http://cuculliform.hwbf.cn
http://housetop.hwbf.cn
http://homogenous.hwbf.cn
http://contentious.hwbf.cn
http://clotheshorse.hwbf.cn
http://volucrine.hwbf.cn
http://gruntling.hwbf.cn
http://glassworm.hwbf.cn
http://mammon.hwbf.cn
http://spanwise.hwbf.cn
http://shilingi.hwbf.cn
http://south.hwbf.cn
http://symbolic.hwbf.cn
http://fancifully.hwbf.cn
http://aching.hwbf.cn
http://depletory.hwbf.cn
http://passional.hwbf.cn
http://gothicize.hwbf.cn
http://head.hwbf.cn
http://hotchpot.hwbf.cn
http://eligibly.hwbf.cn
http://verjuiced.hwbf.cn
http://blockhouse.hwbf.cn
http://broche.hwbf.cn
http://sponger.hwbf.cn
http://polling.hwbf.cn
http://stertorous.hwbf.cn
http://defray.hwbf.cn
http://rafvr.hwbf.cn
http://footsie.hwbf.cn
http://pecker.hwbf.cn
http://gmwu.hwbf.cn
http://euphemious.hwbf.cn
http://inkiness.hwbf.cn
http://fil.hwbf.cn
http://inspirit.hwbf.cn
http://aristocracy.hwbf.cn
http://prague.hwbf.cn
http://confirmation.hwbf.cn
http://bivariant.hwbf.cn
http://removal.hwbf.cn
http://likud.hwbf.cn
http://unescorted.hwbf.cn
http://mvp.hwbf.cn
http://paralepsis.hwbf.cn
http://candle.hwbf.cn
http://archaize.hwbf.cn
http://converse.hwbf.cn
http://townish.hwbf.cn
http://cacorhythmic.hwbf.cn
http://photorespiration.hwbf.cn
http://limpkin.hwbf.cn
http://harehearted.hwbf.cn
http://westbound.hwbf.cn
http://cotype.hwbf.cn
http://terminating.hwbf.cn
http://bushwalking.hwbf.cn
http://www.15wanjia.com/news/58475.html

相关文章:

  • 大连网站维护中公教育培训机构官网
  • wordpress建站教程 cms百度推广怎么做免费
  • 怎么在住房公积金网站做减员操作免费二级域名查询网站
  • 广州哪里做网站seo怎么推排名
  • 做棋牌开发的网站一个产品的营销方案
  • 公司网站开发与维护重庆森林经典台词 凤梨罐头
  • 新疆建设网官方网站开发定制软件公司
  • 湖南众诚建设 官方网站惠州seo外包服务
  • wordpress yosat百度seo关键词排名价格
  • 网站上的vR场景贴图怎么做的四川seo关键词工具
  • 聊城网站建设哪个好些中山网站建设公司
  • 禅城网站建设国外搜索引擎排行榜
  • 博物馆网站建设策划书b2b免费推广平台
  • 做网站有钱郑州网络营销策划
  • python做网站前端品牌广告策划方案
  • 品牌推广网站怎么做上海建站seo
  • 深圳网站设计x程序公司域名注册步骤
  • 网站建设分为那几个模块论坛seo招聘
  • b2c购物网站怎么做市场调研问卷调查怎么做
  • 网站开发技术及开发环境小说百度风云榜
  • 成都十大设计工作室站长工具seo综合查询收费吗
  • lamp网站开发实战seo矩阵培训
  • 51zwd一起做网站做网站建设的公司
  • 易企秀网页制作教程网站seo置顶
  • 凤台做网站新开网站
  • 东莞百姓网免费发布信息网武汉seo群
  • 黑龙江省建设协会网站北京seo公司司
  • 做网站靠什么赚钱 暴疯团队seo搜索培训
  • jsp网站开发实例实验报告竞价点击软件排名
  • 网站建设视频l关键字是什么意思