设为首页 加入收藏

TOP

hdu 4870 Rating(概率DP&高数消元)
2015-07-20 18:01:51 来源: 作者: 【 】 浏览:3
Tags:hdu 4870 Rating 概率 DP& 高数消

Rating

Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 714 Accepted Submission(s): 452
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

Author FZU
Source 2014 Multi-University Training Contest 1
Recommend We have carefully selected several similar problems for you: 4896 4895 4894 4892 4891

题意:

一个人打cf。规则是如果他排名前200就加50分最高加到1000.否侧减100分。最低到0分。现在告诉你他一场比赛前200的概率p.然后他申请了两个账号初始分都为0.每次比赛他会用分数低的那个账号低的那个账号打。现在问你他要上1000.有一个账号上就行了。需要参加比赛场数的期望。

思路:

由于加减分都是50的倍数。所以分数可以用[0,20]表示。没次可以减2分或加1分。用dp[i][j]表示分数高的账号分数为i。分数低的账号分数为j然后有一个账号上1000的概率。

那么dp[i][j]=p*(dp[i][j+1]+1)+(1-p)*(dp[i][j-2]+1) i>j。如果j+1大于i就换成dp[j+1][i]。如果j-2小于0就换成dp[i][0]。然后对每个dp[i][j]编号。建立方程。然后高斯消元。

详细见代码:

#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        using namespace std; const int INF=0x3f3f3f3f; const double eps=1e-11; const int maxn=100010; typedef long long ll; int cnt,mp[50][50]; double mat[310][310]; bool gauss() { int row,i,j,id; double maxx,var; for(row=0;row
       
        maxx) { maxx=fabs(mat[i][row]); id=i; } } if(maxx
        
         =0;i--) { for(j=i+1;j
         
          


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UVA 11402 - Ahoy, Pirates!(线段.. 下一篇HDU 1260 Tickets (动规)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: