zoukankan      html  css  js  c++  java
  • HDU 4870 Rating 概率DP

    Rating
    Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    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
     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <algorithm>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8     int i,j;
     9     double dp[22],p,ans[25][25];
    10     while(scanf("%lf",&p)!=EOF)
    11     {
    12         dp[0]=1.0/p;
    13         dp[1]=1.0/p/p;
    14         ans[0][0]=0;
    15         for(i=2;i<20;i++)
    16         {
    17             dp[i]=1.0/p+(1.0-p)/p*(dp[i-2]+dp[i-1]);
    18         }
    19         for(i=0;i<20;i++)
    20         {
    21             ans[i+1][i]=ans[i][i]+dp[i];
    22             ans[i+1][i+1]=ans[i+1][i]+dp[i];
    23         }
    24         printf("%lf
    ",ans[20][19]);
    25     }
    26     return 0;
    27 }
    View Code
  • 相关阅读:
    js循环遍历弹框,先弹出第一个之后逐步弹出第二个。。
    js获取字符串的字节长度
    tomcat启动报错:Address already in use: JVM_Bind
    自整理的jquery.Validate验证表达式
    jerichotab 初始化页面显示tab页中的第一个
    POST提交大量数据,导致后面数据丢失
    IDEA启动时自动报Plugin Error错误
    apiCloud检出代码出现以下图示错误:
    javascript的一些在IE下不支持的函数小结
    The Nature of Recognition
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771431.html
Copyright © 2011-2022 走看看