题解:

看到了树

很明显就是树形dp吗

然后随便yy一下方程就好了

代码:

#include<bits/stdc++.h>
using namespace std;
int n,j;
double a[],s,k1,c,f1[],f[][][];
int main()
{
cin>>n>>k1>>c;
for (int i=;i<=n;i++)
{
cin>>a[i];
s+=a[i];
}
for (int i=;i<=n;i++) f1[i]=a[i]/s;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int x=;x<=n-;x++)f[i][j][x]=;
for (int i=;i<=n+;i++)
for (int x=;x<=n-;x++)f[i][i][x]=(k1*(x+)+c)*f1[i];
for (int i=;i<=n+;i++)
for (int x=;x<=n;x++)f[i][i-][x]=;
for (int len=;len<=n;len++)
for (int i=;i<=n-len+;i++)
{
int j=i+len-;
for (int x=;x<=n-;x++)
for (int k=i;k<=j;k++)
f[i][j][x]=min(f[i][j][x],f[i][k-][x+]+f[k+][j][x+]+(k1*(x+)+c)*f1[k]);
}
printf("%.3f",f[][n][]);
return ;
}

bzoj1261的更多相关文章

  1. BZOJ1261: [SCOI2006]zh_tree

    Description 张老师根据自己工作的需要,设计了一种特殊的二叉搜索树.他把这种二叉树起名为zh_tree,对于具有n个结点的zh_tree,其中序遍历恰好为(1,2,3,-,n),其中数字1, ...

  2. bzoj千题计划184:bzoj1261: [SCOI2006]zh_tree

    http://www.lydsy.com/JudgeOnline/problem.php?id=1261 dp[l][r][dep]  区间[l,r]内的节点,根在dep层的最小代价 枚举根i,dp[ ...

  3. BZOj1261: [SCOI2006]zh_tree(dp)

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 400  Solved: 272[Submit][Status][Discuss] Descriptio ...

  4. 区间DP复习

    区间DP复习 (难度排序:(A,B),(F,G,E,D,H,I,K),(C),(J,L)) 这是一个基本全在bzoj上的复习专题 没有什么可以说的,都是一些基本的dp思想 A [BZOJ1996] [ ...

随机推荐

  1. git 放弃本地修改

     本文以转移至本人的个人博客,请多多关注! 如果在修改时发现修改错误,而要放弃本地修改时, 一, 未使用 git add 缓存代码时. 可以使用 git checkout -- filepathnam ...

  2. alfred

    1.alfred怎么设置默认的搜索项. https://www.zhihu.com/question/20205127 2.

  3. laravel配置路由除了 / 都是404解决办法

    1.php.ini开启phpopenssl 2.conf  (nginx为例) location / { index index.html index.htm index.php l.php; #tr ...

  4. selenium+Page Objects(第三话)

    写好BasePage基类和页面元素定位后,就可以针对每个页面写业务逻辑了 1.编写每个页面page类,拿其中一个页面为例 fourth_page.py(名字我随便取的,实际中希望能取一些有意义的名字) ...

  5. spring boot+freemarker+spring security标签权限判断

    spring boot+freemarker+spring security标签权限判断 SpringBoot+SpringSecurity+Freemarker项目中在页面上使用security标签 ...

  6. java学习视频

    随着信息化的发展,IT行业变得越来火,在开发领域,Java语言在是市面上很受欢迎的编程语言,很多初学者不知道从何学起,为了找资源浪费大量时间,而我就将自己的寻找资源分享给大家,让大家能够更加便捷的学习 ...

  7. Lab 6-2

    Analyze the malware found in the file Lab06-02.exe. Questions and Short Answers What operation does ...

  8. 6 Django REST framework JWT 和登录功能实现

    JWT 在用户注册或登录后,我们想记录用户的登录状态,或者为用户创建身份认证的凭证. 我们不再使用Session认证机制,而使用Json Web Token认证机制. Json web token ( ...

  9. MVC实战之排球计分(三)—— 模型类的设计与实现

    此软件使用的数据库连接方式code first 由EF框架产生数据库. code first需要对模型类设计和实现.模型类是现实实体在计算机中的表示.它贯穿于整个架构, 负担着在各层次及模块间传递数据 ...

  10. leetcode-algorithms-13 Roman to Integer

    leetcode-algorithms-13 Roman to Integer Roman numerals are represented by seven different symbols: I ...