Rating - HDU 4870 期望dp
来源:互联网 发布:好弹幕软件下载 编辑:程序博客网 时间:2024/05/18 01:32
Rating
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 403 Accepted Submission(s): 254
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.0000000.814700
Sample Output
39.00000082.181160
题意:一个人有两个账号,每次用积分少的号比赛,有p的概率加50分,还有1-p的概率减100分,最低减到0,问有一个号到1000分的期望是多少。
思路:dp[i]表示从i分增加到i+1分的期望。dp[i]=p+(1-p)*(dp[i-2]+dp[i-1]+dp[i]+1)。整理后dp[i]=1/p+(1-p)/p*(dp[i-2]+dp[i-1]); dp[0]=1/p,dp[1]=1/p/p。然后就可以推出结果了。
AC代码如下:
#include<cstdio>#include<cstring>using namespace std;double dp[30],ans[30][30],p;int main(){ int i,j,k; while(~scanf("%lf",&p)) { dp[0]=1/p; dp[1]=1/p/p; for(i=2;i<=19;i++) dp[i]=1/p+(1-p)/p*(dp[i-2]+dp[i-1]); for(i=0;i<=20;i++) { ans[i+1][i]=ans[i][i]+dp[i]; ans[i+1][i+1]=ans[i+1][i]+dp[i]; } printf("%.6f\n",ans[20][19]); }}
0 0
- Rating - HDU 4870 期望dp
- hdu 4870 Rating(高斯消元求期望)
- HDU 4870 Rating 高斯消元求期望
- 【HDU 4870】Rating【DP】
- 【HDU】4870 Rating 概率DP
- hdu 4870 Rating 概率dp
- hdu 4870 Rating (概率dp)
- HDU 4870 Rating(概率dp+高斯消元)
- hdu 4870 Rating (概率dp)
- hdu 4870 Rating(概率DP&高数消元)
- hdu 4870 Rating (高斯消元解概率dp)
- HDU 4870 Rating 概率DP(高斯消元)
- hdu 4870 Rating 多校第一场 概率dp
- hihocoder 1166 交换代数|HDU 4870 Rating 等(区间翻转,高斯消元求期望)
- hdu 4870 Rating
- HDU 4870 Rating(高斯消元)
- hdu-4870-Rating
- hdu 4870 Rating
- Android_LogCat错误汇总
- 我的学习之旅:android自定义Dialog
- 杭电1021递归太严重,过不了
- 并查集
- 四种操作xml的方式: SAX, DOM, JDOM , DOM4J的比较
- Rating - HDU 4870 期望dp
- 杭电1021大神教的
- Android的webview加载本地html、本apk内html和远程URL
- Q13.2
- OpenGL ES Programming Guide for iOS 使用OpenGL ES和GLKit绘图
- XmlHelper
- poj1611 The Suspects
- snprintf函数
- 杭电1406先前写的一个错误,因为没有注意给的a,B不一定是A》B所以错误,先确定A,B大小才可以