Rating

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 578    Accepted Submission(s): 363
Special Judge

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

看了官方题解表示还未太明白,而听说到更变态的dp

首先将50分积到1000 简化为 1积到20

f[i] 表示 从第 i 分  到 i+1 分 的期望比赛次数

则 f[i] = p + (1-p) * ( 1+ f[i-2] + f[i-1] + f[i] )

f[i] = (1-p) / p * ( f[i-1] + f[i-2] ) + 1/p

其中 易得到 f[0]=1/p f[1]=p+(1-p)*(1+f[0]+f[1]) 得到 f[1]=1/p^2

则可推出

  ans[i][j] 表示其中一个赢i分另一个赢j分,已得到两者相差不会超过1分,达到这种分数的期望比赛次数。

  所以可以得到相应的递推式

    ans[i+1][i]=ans[i][i]+f[i];

    ans[i+1][i+1]=ans[i+1][i]+f[i];

  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. double p;
  6. double f[],ans[][];
  7. int main()
  8. {
  9. while(scanf("%lf",&p)!=EOF){
  10. f[]=1.0/p;
  11. f[]=f[]/p;
  12. for(int i=; i<; i++)
  13. f[i]=(-p)/p*(f[i-]+f[i-])+1.0/p;
  14. ans[][]=;
  15. for(int i=; i<; i++){
  16. ans[i+][i]=ans[i][i]+f[i];
  17. ans[i+][i+]=ans[i+][i]+f[i];
  18. }
  19. printf("%.6f\n",ans[][]);
  20. }
  21. return ;
  22. }

HDU 4870 Rating (2014 Multi-University Training Contest 1)的更多相关文章

  1. HDU 4870 Rating (2014 多校联合第一场 J)(概率)

    题意: 一个人有两个TC的账号,一开始两个账号rating都是0,然后每次它会选择里面rating较小的一个账号去打比赛,每次比赛有p的概率+1分,有1-p的概率-2分,当然如果本身是<=2分的 ...

  2. HDU 4870 Rating(概率、期望、推公式) && ZOJ 3415 Zhou Yu

    其实zoj 3415不是应该叫Yu Zhou吗...碰到ZOJ 3415之后用了第二个参考网址的方法去求通项,然后这次碰到4870不会搞.参考了chanme的,然后重新把周瑜跟排名都反复推导(不是推倒 ...

  3. hdu 4870 Rating

    题目链接:hdu 4870 这题应该算是概率 dp 吧,刚开始看了好几个博客都一头雾水,总有些细节理不清楚,后来看了 hdu 4870 Rating (概率dp) 这篇博客终于有如醍醐灌顶,就好像是第 ...

  4. HDU 4870 Rating(高斯消元 )

    HDU 4870   Rating 这是前几天多校的题目,高了好久突然听旁边的大神推出来说是可以用高斯消元,一直喊着赶快敲模板,对于从来没有接触过高斯消元的我来说根本就是一头雾水,无赖之下这几天做DP ...

  5. HDU 4870 Rating 概率DP

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

  6. hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...

  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(高斯消元求期望)

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

  9. HDU 6143 - Killer Names | 2017 Multi-University Training Contest 8

    /* HDU 6143 - Killer Names [ DP ] | 2017 Multi-University Training Contest 8 题意: m个字母组成两个长为n的序列,两序列中 ...

随机推荐

  1. java synchronized(一)

    java synchronized主要用于控制线程同步,中间有很多小的细节,知识,这里我简单的整理一下,做个记录.主要用于方法和代码块的控制 先说说方法控制 模拟银行存款和取款,创建一个Account ...

  2. “Microsoft Visual Studio遇到了问题,需要关闭”解决办法

    运行VS2008,打开项目,弹出错误界面 . 解决办法:将项目中的所有设计窗体关闭并保存,重新打开就OK~

  3. iOS xcode 8 注释快捷键

    单行注释:在方法的地方按 Command+/ 标注的功能,快捷键是Command + Option + / 需要在方法名的上面(空白)的地方按 Command + Option + /      才管 ...

  4. 好项目烂架构的问题,四年coder的吐槽

    四年多码农,毕业后在一家小私企做前端:(初始asp.net,对oo有了比较深切的理解:处于对某空间的效仿,对前端技术架构理解的比较透彻): 在这家公司混了4个月之后跳出来想自己单干: 自己接了个小项目 ...

  5. Careercup - Facebook面试题 - 5110993575215104

    2014-04-30 16:12 题目链接 原题: The beauty of a number X is the number of 1s in the binary representation ...

  6. Django 学习笔记之四 QuerySet常用方法

    QuerySet是一个可遍历结构,它本质上是一个给定的模型的对象列表,是有序的. 1.建立模型: 2.数据文件(test.txt) 3.文件数据入库(默认的sqlite3) 入库之前执行 数据库同步命 ...

  7. jquery each函数对应的continue 和 break方法

    continue: return true; break: return false; $("#oGrid").each(function (i, v) { if (i == 0) ...

  8. apache nginx php不显示版本号

    apache 不显示版本号 http.conf 中的 修改为 ServerTokens ProdServerSignature Off 有的版本没有,在最后添加即可 php php.ini 中的 修改 ...

  9. 从String类看写C++ class需要注意的地方

    #include <iostream> #include <string.h> using namespace std; class String { char* m_data ...

  10. Http、tcp、Socket连接区别

    转自Http.tcp.Socket连接区别 相信不少初学手机联网开发的朋友都想知道Http与Socket连接究竟有什么区别,希望通过自己的浅显理解能对初学者有所帮助. 1.TCP连接 要想明白Sock ...