HDU5236 Article(期望dp)
来源:互联网 发布:华康字体淘宝可以用吗 编辑:程序博客网 时间:2024/06/05 23:41
Article
传送门1
传送门2
As the term is going to end, DRD begins to write his final article.
DRD uses the famous Macrohard’s software, World, to write his article. Unfortunately this software is rather unstable, and it always crashes. DRD needs to write
Since World crashes too often, now he is asking his friend ATM for the optimal strategy to input his article. A strategy is measured by its expectation keys DRD needs to press.
Note that DRD can press a key at fast enough speed.
Input
First line: an positive integer
Next T lines: each line has a positive integer
Output
For each test case: output ”Case #k: ans” (without quotes), where
Your answer is considered correct if and only if the absolute error or the relative error is smaller than
Sample Input
2
1 0.5 2
2 0.4 2
Sample Output
Case #1: 4.000000
Case #2: 6.444444
题意
你现在要打n个字符,但是程序随时可能会崩溃。
你可以在恰当的时机按下 Ctrl−S键,崩溃后,会从最后一次保存的情况继续开始打字。
1. 在每个第
2. 在每个第
3. 在每个第
求采取最优策略下,打完这
分析
定义
因为敲第
然后进行类似解方程的操作得到
另外,我们可以发现dp数组是指数增长的,而且
CODE
#include<cstdio>#define N 100005typedef double db;int n,x;db p,dp[N];inline void Min(db &x,db y) {if(x>y)x=y;}int main() { int t; scanf("%d",&t); for(int cas=1; cas<=t; cas++) { scanf("%d%lf%d",&n,&p,&x); for(int i=1; i<=n; i++)dp[i]=(dp[i-1]+1)/(1-p); db ans=dp[n]+x; for(int i=2; i<=n; i++)Min(ans,dp[n/i+1]*(n%i)+dp[n/i]*(i-n%i)+i*x); printf("Case #%d: %.6f\n",cas,ans); } return 0;}
- HDU5236 Article(期望dp)
- hdu5236 Article(贪心+概率dp)
- hdu5236 Article
- HDU5236(概率DP,贪心)
- Hdu 5236 Article【思维+期望Dp】
- hdu 4649 (期望dp)
- hdu-3853(dp+期望)
- zoj-3329(***期望+dp)
- poj2096 (dp求期望)
- HDU_5781_ATM_Mechine(概率期望dp)
- bzoj1419(期望与DP)
- [BZOJ3450]Easy(期望dp)
- [BZOJ4318]OSU!(期望dp)
- hdu 3853(期望dp)
- book书 (期望dp)
- hdu 4405(期望dp)
- poj 2096(期望dp)
- hdu 5781(期望dp)
- 【数据结构】[NOIP2013]火柴排队
- POJ2891 Strange Way to Express Integers
- P2592 [ZJOI2008]生日聚会
- <C++> const总结
- 坚持#第230天~零基础自学云计算基础语言应用之python第6节
- HDU5236 Article(期望dp)
- XJOI泡泡糖
- (二十八)RecyclerView ItemTouchHelper 源码分析以及拓展
- [BZOJ4870][SHOI2017]组合数问题 DP+矩阵快速幂
- xUtils的4个用法
- 【模板】线段树区间修改、区间求和、查询最值
- Balanced Binary Tree:判断一棵树是否为平衡二叉树
- 归并排序
- Python菜鸟教程(一)-爬b站数据