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 ...
随机推荐
- GoLang之错误处理
错误处理 error Go语言引入了一个错误处理的标准模式,即error接口,该接口定义如下: type error interface { Error() string } 对于大多数函数,如果要返 ...
- UNION ALL的用法
" ?> -mapper.dtd" > <mapper namespace="com.j1.soa.resource.order.oracle.dao. ...
- 【Zookeeper系列】ZooKeeper管理分布式环境中的数据(转)
原文地址:https://www.cnblogs.com/sunddenly/p/4092654.html 引言 本节本来是要介绍ZooKeeper的实现原理,但是ZooKeeper的原理比较复杂,它 ...
- [原][openstack-pike][controller node][issue-4][horizon] dashboard access too low reasons[dashboard 访问太慢]
本文持续更新... 原因一: 访问dashboard 很慢. 输入了用户名和密码还有project后,一直处于首页状态,等很久才进入(暂且不考虑硬件.硬件暂时假设都满足条件) 首先想到的是memca ...
- js 日期排序(sort)
按创建时间日期排序 例如 eg 1.升序 2.降序 返回的结果: 注: 支持IE和Chrome其他的浏览器可自行测试
- 方差+标准差+四分位数+z-score公式
一.方差公式 $S^2 = \frac{1}{N}\sum_{i=1}^{N}(X_i - \mu)^2 = \frac{1}{N}[(X_1-\mu)^2 + (X_2-\mu)^2 + ... + ...
- ArcGIS AddIN开发之 设置当前工具为Edit Tool
在GIS数据处理中,经常需要选择要素,再进行操作.所以,为了处理的方便,可以将当前工具处理结束后,将当前工具设置为Edit Tool,以方便下一次的选择处理. 相关资料: 1.ArcMap Name ...
- Matplotlib学习
决定通过一个个例子来实践并掌握Matplotlib.. 例子1. 画一个散点图,数据分布如下: import numpy as np import pandas as pd import matplo ...
- javascript的数组之from()
Array.from()方法从一个类似数组或可迭代对象中创建一个新的数组实例. const arr = [1, 2, 3]; Array.from(arr); //[1, 2, 3] Array.fr ...
- HTML、CSS知识点,面试开发都会需要--No.2 CSS
No.2 CSS 1.选择器类型 选择器类型包括:type.class.id. 2.引用外部css文件 使用link元素,添加rel和href属性:<link rel="styles ...