Problem Description
A little girl loves programming competition very much. Recently, she has found a new kind of programming competition named "TopTopTopCoder". Every user who has registered in "TopTopTopCoder" system will have a rating, and the initial value of rating equals
to zero. After the user participates in the contest held by "TopTopTopCoder", her/his rating will be updated depending on her/his rank. Supposing that her/his current rating is X, if her/his rank is between on 1-200 after contest, her/his rating will be min(X+50,1000).
Her/His rating will be max(X-100,0) otherwise. To reach 1000 points as soon as possible, this little girl registered two accounts. She uses the account with less rating in each contest. The possibility of her rank between on 1 - 200 is P for every contest.
Can you tell her how many contests she needs to participate in to make one of her account ratings reach 1000 points?
 
Input
There are several test cases. Each test case is a single line containing a float number P (0.3 <= P <= 1.0). The meaning of P is described above.
 
Output
You should output a float number for each test case, indicating the expected count of contest she needs to participate in. This problem is special judged. The relative error less than 1e-5 will be accepted.
 
Sample Input
1.000000
0.814700
 
Sample Output
39.000000
82.181160
由于每次50分,到达1000分,所以能够看做每次1分。到达20分
dp[i]表示i到20的数学期望
那么dp[i] = dp[i+1]*p+dp[i-2]*q+1;
令t[i] = dp[i+1]-dp[i]
则t[i] = (t[i+1]*p+t[i-2]*q)
所以t[i+1] = (t[i]-t[i-2]*q)/p
#include <stdio.h>
int main()
{
float p,sum,t[21],q;
int i;
while(~scanf("%f",&p))
{
sum = 0;
q = 1-p;
t[0] = 1/p,t[1] = t[0]/p,t[2] = t[1]/p;
sum = t[0]+t[1]+t[2];
for(i = 3;i<20;i++)
{
t[i] = (t[i-1]-t[i-3]*q)/p;
sum+=t[i];
}
printf("%.6f\n",sum*2-t[19]);
}
return 0;
}

HDU4870:Rating(DP)的更多相关文章

  1. hdu4870 Rating (高斯消元或者dp)

    Rating Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  2. HDU4870 Rating(概率)

    第一场多校,感觉自己都跳去看坑自己的题目里去了,很多自己可能会比较擅长一点的题目没看,然后写一下其中一道概率题的题解吧,感觉和自己前几天做的概率dp的思路是一样的.下面先来看题意:一个人有两个TC的账 ...

  3. TTTTTTTTTTT hdu 1520 Anniversary party 生日party 树形dp第一题

    Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. hdu1520 Anniversary party

    Anniversary party HDU - 1520 题意:你要举行一个晚会,所有人的关系可以构成一棵树,要求上下级关系的人不能同时出现,每一个人都有一个rating值,要求使整个晚会的ratin ...

  5. HDU 4870 Rating 概率DP

    Rating Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  6. 2014多校第一场J题 || HDU 4870 Rating(DP || 高斯消元)

    题目链接 题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的 ...

  7. hdu 4870 Rating(可能性DP&amp;高数消除)

    Rating Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  8. 【HDU 4870】Rating【DP】

    题意:一个人注冊两个账号,初始rating都是0,他每次拿低分的那个号去打比赛,赢了加50分,输了扣100分.胜率为p,他会打到直到一个号有1000分为止,问比赛场次的期望. 题解:因为每次添加分数或 ...

  9. POJ 2342 Anniversary party(树形dp)

    Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7230   Accepted: 4162 ...

随机推荐

  1. go 冒泡排序

    package main import ( "fmt" ) func main() { a := [...], , , , , , , , , } num := len(a) fm ...

  2. MFC TCHAR 和CHAR相互转换

    没有定义UNICODE,所以它里面的字符串就是简单用" "就行了,创建工程的时候包含了UNICODE定义,就必须对TCHAR和char进行转换. 首先是把TCHAR转为char / ...

  3. 怎样在Android实现桌面清理内存简单Widget小控件

    怎样在Android实现桌面清理内存简单Widget小控件 我们常常会看到类似于360.金山手机卫士一类的软件会带一个widget小控件,显示在桌面上,上面会显示现有内存大小,然后会带一个按键功能来一 ...

  4. Keywords Search (ac 自己主动机)

    Keywords Search Problem Description In the modern time, Search engine came into the life of everybod ...

  5. AMFPHP1.4与PHP5.3及以上版本号不兼容问题的解决

    近期在升级PHP5.4版本号,AMFPHP出现了兼容性问题.解决过程记录例如以下. 1.ereg类相关函数改动为preg相关函数. 2.通过错误日志输出的提示.将全部以静态方式调用的类函数加入stat ...

  6. 使用Ajax以及Jquery.form异步上传图片

    一.前言 之前做图片上传一直用的第三方插件,Uploadify  这个应该是用的比較多的,相同也用过别的,在方便了自己的同一时候也非常赞叹人家的功能. 思来想去,仅仅会用别的人东西,始终自己学到的少, ...

  7. 基于HTTP和TFTP的PXE批量自动化安装Linux系统

    CentOS 6.5 PXE自动化部署系统 拓扑图如下: 步骤: 1.  安装http服务,上传ISO文件 [root@UCS-1 ~]# yum install httpd –y [root@UCS ...

  8. mysql登录报错 ERROR 1045 (28000)

    1.现象: [root@localhost ~]# mysql -u root -p Enter password:  ERROR 1045 (28000): Access denied for us ...

  9. 【Bug Fix】Error : Can&#39;t create table &#39;moshop_1.#sql-534_185&#39; (errno: 150)

    运行alter操作, alter table xx_shop_info add index FK9050F5D83304CDDC (shop_area), add constraint FK9050F ...

  10. hadoop每个家庭成员

    本文没有提到的原则.谈论hadoop项目周边,它的作用. hadoop这个词已经流行了很多年.大数据的记载会认为hadoop,然后hadoop的作用是什么呢? 官方定义:hadoop是一个开发和执行处 ...