hdu5236 Article
概率DP
$dp_i$表示连打$i$个字符的期望按键数
那么枚举保存的次数,均分一下连打的个数就好
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#define re(i,l,r) for(int i=(l);i<=(r);i++)
#define rre(i,r,l) for(int i=(r);i>=(l);i--)
using namespace std;
int n,x;
double p;
double dp[];
int main()
{
int t,tt;
scanf("%d",&t);tt=t;
while(t--)
{
scanf("%d%lf%d",&n,&p,&x);
re(i,,n)dp[i]=(dp[i-]+)/(-p);
double ans=dp[n]+x;
re(i,,n)
{
int shu=n/i;
if(n%i)ans=min(ans,dp[shu+]*(n%i)+dp[shu]*(i-n%i)+i*x);
else ans=min(ans,dp[shu]*i+i*x);
}
printf("Case #%d: %.6f\n",tt-t,ans);
}
return ;
}
hdu5236 Article的更多相关文章
- Python爬取CSDN博客文章
0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...
- http://blog.csdn.net/java2000_wl/article/details/8627874
http://blog.csdn.net/java2000_wl/article/details/8627874
- [Android Pro] http://blog.csdn.net/wuyinlei/article/category/5773375
http://blog.csdn.net/wuyinlei/article/category/5773375
- android 蓝牙 http://blog.csdn.net/u012843100/article/details/52384219
http://blog.csdn.net/u012843100/article/details/52384219
- HTML中的div,section,article的区别
刚开始看到标签的就有些疑惑,觉得为什么有那么多相同用途的标签,多方查询资料细细比较之后才发现原来各有千秋,结合自己的想法总结如下: div在HTML早期版本就支持了,section和article是H ...
- article和section
article和section都是指页面中的块,但是article更加强调独立性,而section常被用来分块. section使用禁忌: 1.不要把section当作定义样式的容器,因为那是div的 ...
- http://blog.csdn.net/krislight/article/details/9391455
http://blog.csdn.net/krislight/article/details/9391455
- http://blog.csdn.net/shawnkong/article/details/52045894
http://blog.csdn.net/shawnkong/article/details/52045894
- Urban Planning and Public Health - Reflection on Professor Webster's article in Urban Planning Forum
1. General review. Professor Webster published this article in Urban Planning Forum, one of the top ...
随机推荐
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
现象: ERROR : The processing instruction target matching "[xX][mM][lL]" is not allowed. 异 ...
- IntelliJ IDEA License Server 安装使用 Mac篇
一.下载 IntelliJ IDEA 是Java开发利器,用社区版不爽,干催就用旗舰版,这个是收费的,需要licence. IntelliJ IDEA下载地址:https://www.jetbrai ...
- 真-关闭win10安全中心(windows defender)
狂客原创,转载请注明.侵权必究 第一 任务管理器 启动项 禁用 第二 使用win+R,打开运行命令输入:gpedit.msc然后点击确定 在管理模块下找到Windows组件,接续打开下拉菜单,找到Wi ...
- proxy_set_header Host 所引发的凶案
背景介绍:新搭建了一套测试环境.slb为2.2.2.2,由于应用的特殊性,需要走 test.aaa.com.cn 域名,而该域名在老的测试服务器1.1.1.1有两个不能迁移的服务也在使用,故想出对策, ...
- 接口自动化测试 (三)request.post
上一节介绍了 requests.get() 方法的基本使用,本节介绍 requests.post() 方法的使用: 本文目录: 一.方法定义 二.post方法简单使用 1.带数据的post 2 ...
- DEMO大全,超赞【申明:来源于网络】
DEMO大全,超赞[申明:来源于网络] 地址:http://www.verydemo.com/one_c55.html
- Feign 客户端源码解析
Feign的使用非常简单,增加如下配置之后,便可以使用Feign进行调用.非常简单是不是.主要的工作由Feign框架完成.业务代码只提供了一个Interface, 然后由Feign动态生成代理类来实现 ...
- hive on spark配置
1.安装java.maven.scala.hadoop.mysql.hive 略 2.编译spark ./make-distribution.sh --name "hadoop2-witho ...
- 复习C++:VS2008中的宏干嘛用的
VS2008中有宏,可也进行编辑和设置. 好处: 1.快速生成代码,帮助开发. 2.个人定制化功能,IDE更合适自己用. 3.提升编程效率. 缺点: 使用VB开发,一开始用起来费事.不过有官方参考 ...
- python 中的__new__与__init__
在Python中的class中有两个方法__new__与__init__,有什么区别呢? class TestCls(): """docstring for TestCl ...