HDU 4870 Rating (2014 Multi-University Training Contest 1)

时间:2023-01-15 12:19:13

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 &lpar;2014 多校联合第一场 J&rpar;&lpar;概率&rpar;

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

  2. HDU 4870 Rating(概率、期望、推公式) &amp&semi;&amp&semi; 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&lpar;可能性DP&amp&semi;amp&semi;高数消除&rpar;

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

  8. hdu 4870 rating&lpar;高斯消元求期望&rpar;

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

  9. HDU 6143 - Killer Names &vert; 2017 Multi-University Training Contest 8

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

随机推荐

  1. &lbrack;zz&rsqb;如何在C语言程序中处理汉字

    学习过C语言的人也许有时会遇到这样一个问题:如何用变量存储汉字以及对这些变量进行操作.目前许多C语言参考书中都没涉及到这个问题,程序中多为处理英文变量和英文字符串,涉及到汉字的情况也大都是在print ...

  2. &lbrack;转&rsqb;Android使用WebView从相册&sol;拍照中添加图片

    原地址:http://blog.csdn.net/djcken/article/details/46379929 解决这个问题花了很长时间搜索了解,网上大部分使用openFileChooser但都没解 ...

  3. 利用LruCache为GridView异步加载大量网络图片完整示例

    MainActivity如下: package cc.testlrucache; import android.os.Bundle; import android.widget.GridView; i ...

  4. 项目演化系列--验证体系&lpar;基于angular的前端验证&rpar;

    前言 之前分享的<web项目演化--验证体系>中提到基于angular的验证,但是为了以防读者迷惑,能够好的理解验证体系,所以没有详细介绍. 今天特地补写一篇关于构建angular的验证. ...

  5. C&num; 编写Window服务基础(一)

    一.Windows服务介绍: Windows服务以前被称作NT服务,是一些运行在Windows NT.Windows 2000和Windows XP等操作系统下用户环境以外的程序.在以前,编写Wind ...

  6. cloudera manager 及CDH卸载

    记录用户数据路径 删除用户数据 中列出的用户数据路径 /var/lib/flume-ng /var/lib/hadoop* /var/lib/hue /var/lib/navigator /var/l ...

  7. javascript 将多维数组转换为一维数组

    /** * 2013年9月去面试的时候,有面试过这样子一道题目: * 题目是这样子的:将一个多维数组转换成一维数组并返回该数组,类似 * [1,2,3,[4,5,6,[7,8]],9]转换后为:[1, ...

  8. How many ways

    How many ways Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  9. os项目icon和default 等相关图标命名规则和大小设置

    最新的参考apple官网地址:https://developer.apple.com/library/ios/qa/qa1686/_index.html,网页下面有详细的使用方法(ios7以后的) 转 ...

  10. LeetCode 289&period; Game of Life (生命游戏)

    According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellul ...