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];

#include <iostream>
#include <cstdio>
using namespace std; double p;
double f[],ans[][];
int main()
{
while(scanf("%lf",&p)!=EOF){
f[]=1.0/p;
f[]=f[]/p;
for(int i=; i<; i++)
f[i]=(-p)/p*(f[i-]+f[i-])+1.0/p;
ans[][]=;
for(int i=; i<; i++){
ans[i+][i]=ans[i][i]+f[i];
ans[i+][i+]=ans[i+][i]+f[i];
}
printf("%.6f\n",ans[][]);
}
return ;
}

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. OC类的本质,深入探讨,load方法和initialize方法

    1:类的本质:类也是一种类,可以叫做类类,类对象,类类型: 2:类和对象在内存中分配问题(注意区分类的对象和类对象的概念) 类对象在内存中只有一份,且只加载一次,类对象中存放了类中定义的方法: 而成员 ...

  2. python调用C语言

    标签(空格分隔): python test.c代码如下 #include<stdio.h> void display(char* msg) { printf("%s\n" ...

  3. javascript_22_for_二维数组

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. java,图片压缩,略缩图

    在网上找了两个图片的缩放类,在这里分享一下: package manager.util; import java.util.Calendar; import java.io.File; import ...

  5. js--eval函数

    前言: js的eval函数很牛叉,用了几次--不过都没有记录.试想:如果没有EXT.JQery,怎样将json字符串转换为对象呢? 示例: 定义2个字符串变量s1.s2.其中s1表示一个对象:s2表示 ...

  6. ApplicationContext

    参考网址: http://baike.baidu.com/link?url=IPzNiVScxSd6ijhDeCKKEuywPqisDeTfyYSQIPRZqLxy6onkPddfzyvcWQC6_M ...

  7. Android工具包

    Eclipse + ADT +SDK,下载ADT Bundle全包含 adt-bundle-windows-x86_64-20140702 http://www.cnblogs.com/tc310/p ...

  8. 【转载】C#.Net 创建网页快捷方式

    using System.Runtime.InteropServices; using IWshRuntimeLibrary; // 添加引用:COM下Windows Script Host Obje ...

  9. wordpress数据库优化-关闭日志修订

    每次在wordpress网站修改文章的时候都会产生一个修订版本,wp_posts会产生一个post_type为“REVISIONS”的记录,修改次数一多的话,那修订版本就有几万条记录了 在functi ...

  10. unity与Android相互调用

    原地址:http://www.cnblogs.com/ayanmw/p/3727782.html 现在unity 导出的android客户端需要调用 Android 的支付SDK,但是unity与an ...