HDU4870:Rating(DP)「建议收藏」

HDU4870:Rating(DP)

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

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
由于每次50分,到达1000分,所以能够看做每次1分。到达20分
dp[i]表示i到20的数学期望
那么dp[i] = dp[i+1]*p+dp[i-2]*q+1;
令t[i] = dp[i+1]-dp[i]
则t[i] = (t[i+1]*p+t[i-2]*q)
所以t[i+1] = (t[i]-t[i-2]*q)/p
#include <stdio.h>
int main()
{
    float p,sum,t[21],q;
    int i;
    while(~scanf("%f",&p))
    {
        sum = 0;
        q = 1-p;
        t[0] = 1/p,t[1] = t[0]/p,t[2] = t[1]/p;
        sum = t[0]+t[1]+t[2];
        for(i = 3;i<20;i++)
        {
            t[i] = (t[i-1]-t[i-3]*q)/p;
            sum+=t[i];
        }
        printf("%.6f\n",sum*2-t[19]);
    }
    return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116723.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Spring Boot面试杀手锏————自动配置原理

    Spring Boot面试杀手锏————自动配置原理引言不论在工作中,亦或是求职面试,SpringBoot已经成为我们必知必会的技能项。除了某些老旧的政府项目或金融项目持有观望态度外,如今的各行各业都在飞速的拥抱这个已经不是很新的Spring启动框架。当然,作为SpringBoot的精髓,自动配置原理的工作过程往往只有在“面试”的时候才能用得上,但是如果在工作中你能够深入的理解SpringBoot的自动配置原理,将无往不利。Spr…

    2022年6月15日
    25
  • 动静分离架构[通俗易懂]

    动静分离架构[通俗易懂]1.应用场景了解更多,根据具体场景选用不用的技术进行架构优化. 2.学习/操作 一、静态页面 静态页面,是指互联网架构中,几乎不变的页面(或者变化频率很低),例如: 首页等html页面 js/css等样式文件 jpg/apk等资源文件 静态页面,有与之匹配的技术架构来加速,例如: CDN ngi…

    2022年4月29日
    47
  • 输入代码自动生成名称_变量命名工具codelf

    输入代码自动生成名称_变量命名工具codelfCodeifCodeIfhttps://unbug.github.io/codelf/包含流行语言,java,c,javaScript,python等等

    2022年9月21日
    4
  • 蓝桥杯单片机必备知识—–(11)EEPROM

    蓝桥杯单片机必备知识—–(11)EEPROM

    2021年4月14日
    156
  • 【11】进大厂必须掌握的面试题-持续集成面试

    Q1。持续集成是什么意思? 我将建议您通过对持续集成(CI)进行小的定义来开始此答案。这是一种开发实践,要求开发人员每天多次将代码集成到共享存储库中。然后,每个签入均由自动构建进行…

    2020年10月20日
    325
  • mpc hc设置_mpc是指什么

    mpc hc设置_mpc是指什么MPC-HC播放器设置启动 MPC-HC ,先设置语言:(最新版本会自动选择对应的系统语言)View-Language-Chinese=>界面变为中文进 视图-选项:播放器:建议勾选「保存设置至.ini文件中」格式:建议勾选全部视频类格式,其中 QuickTime 建议采用「DirectShow」滤镜(双击右侧,在下拉框中即可选择),播放性能会

    2025年11月14日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号