HDU 4870 Rating probability dp

Source: Internet
Author: User
Tags float number

RatingTime limit:5000MS Memory Limit:32768KB 64bit IO Format:%i64d &%i64 U SubmitStatusPracticeHDU 4870

Description

A little girl loves programming competition very much. Recently, she has found a new kind of programming competition named "Toptoptopcoder". Every user who had registered in "Toptoptopcoder" system would have a rating, and the initial value of rating equals to Zer O. After the user participates in the contest held by "Toptoptopcoder", her/his rating would be updated depending on Her/hi S rank. Supposing that her/his current rating are X, if her/his rank is between on 1-200 after contest, her/his rating would be min ( x+50,1000). her/his rating would be Max (x-100,0) otherwise. To reach points as soon-possible, this little girl registered, accounts. She uses the account with less rating in each contest. The possibility of her rank between on 1-200 are P for every contest. Can you tell her about many contests she needs to participate in to make one of his account ratings reach points?

Input

There is several test cases. Each test case was 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 would 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 namespacestd;5 6 intMain ()7 {8     inti,j;9     Doubledp[ A],p,ans[ -][ -];Ten      while(SCANF ("%LF", &p)! =EOF) One     { Adp[0]=1.0/p; -dp[1]=1.0/p/p; -ans[0][0]=0; the          for(i=2;i< -; i++) -         { -dp[i]=1.0/p+ (1.0-p)/p* (dp[i-2]+dp[i-1]); -         } +          for(i=0;i< -; i++) -         { +ans[i+1][i]=ans[i][i]+Dp[i]; Aans[i+1][i+1]=ans[i+1][i]+Dp[i]; at         } -printf"%lf\n", ans[ -][ +]); -     } -     return 0; -}
View Code

HDU 4870 Rating probability dp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.