博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2014 Multi-University Training Contest 1 J - 1010(Rating)
阅读量:5049 次
发布时间:2019-06-12

本文共 2148 字,大约阅读时间需要 7 分钟。

http://acm.hdu.edu.cn/showproblem.php?pid=4870

 

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
 

 

Author
FZU
 

 

Source
 

 

Recommend
We have carefully selected several similar problems for you:            
 
 
 
官方题解暂未看懂, 用动态规划做, 将0-1000分缩成1-20分, f[i]表示一个账号到i分所需次数期望.
f[i] = f[i-1] + p + (1-p)*( 1+f[i]-f[i-3] )
解得  f[i] = [ f[i-1]+p+(1-p)*(1-f[i-3]) ] / p;
解i=1,2时会出现小于0的情况都返回0, 因为f[-1] f[-2]都看做f[0]
两个账号其实完全不想干, 因为一个账号到1000分时另一个一定是950分, 最后结果是f[20]+f[19].

 

double f[30];double p;inline double ff(int x){    return x>=0?f[x]:0;}int main(){    freopen("in.txt","r",stdin);    ios_base::sync_with_stdio(0);    while(scanf("%lf",&p)==1){        memset(f,0,sizeof(f));        //f[1]=1/p;        fer(i,1,21){            f[i] = ( ff(i-1)+p+(1-p)*(1-ff(i-3)) )/p;        }        printf("%.6lf\n",f[20]+f[19] );    }    return 0;}

 

转载于:https://www.cnblogs.com/rewrite/p/3932457.html

你可能感兴趣的文章
mysql忘记root密码
查看>>
apache服务器中设置目录不可访问
查看>>
嵌入式Linux驱动学习之路(十)字符设备驱动-my_led
查看>>
【NOIP模拟】密码
查看>>
java容器---------手工实现Linkedlist 链表
查看>>
three.js 性能优化的几种方法
查看>>
《梦断代码》读书笔记(三)
查看>>
FreeMarker解析json数据
查看>>
Java8 Lambda表达应用 -- 单线程游戏server+异步数据库操作
查看>>
次序+“选择不重复的记录”(3)——最大记录
查看>>
Codeforces 450 C. Jzzhu and Chocolate
查看>>
[Unity3D]Unity3D游戏开发MatchTarget的作用攀登效果实现
查看>>
ACdream 1115 Salmon And Cat (找规律&amp;&amp;打表)
查看>>
JSON、JSONP、Ajax的区别
查看>>
AngularJS学习篇(一)
查看>>
【转载】 IP实时传输协议RTP/RTCP详解
查看>>
关于Xshell无法连接centos6.4的问题
查看>>
Linux系统的数据写入机制--延迟写入
查看>>
css3动画——基本准则
查看>>
javaweb常识
查看>>