hdu4870 Rating---2014 Multi-University Training Contest 1
2014-07-23 00:04
351 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4870
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 171 Accepted Submission(s): 91
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
Sample Output
Author
FZU
Source
2014 Multi-University Training Contest 1
Recommend
We have carefully selected several similar problems for you: 4871 4869 4868 4867 4866
大神们都说这题,应该是高斯消元才对,可惜。。屌丝这方面掌握得实在是太渣了。。。还是没能理解。。。
最后还是看了神牛们神一样的DP思路,才终于理解。。。哎。。惭愧。。。
设dp[i]为从i到i+1所需要的步数则有
dp[i]=p*1+(1-p)*(1+dp[i-2]+dp[i-1]+dp[i]) 化简一下得 dp[i]=1+(1-p)/p*(1+dp[i-2]+dp[i-1])
又由已知条件可得 dp[0]=p*1+(1-p)*(1+dp[0]) 即 dp[0]=1/p
dp[1]=p*1+(1-p)*(1+dp[0]]+dp[1]) 即 dp[1]=1/p+(1-p)/p*(1+dp[0])
设ans[i][j]表示从初状态到两个号的分数为i,j的期望。两个号的分数的变化总是[i,i]->[i+1,i]->[i+1,i+1];每次只有一个号的分数在进行变动。
所以有 ans[i+1][i] = ans[i][i]+dp[i], ans[i+1][i+1] = ans[i+1][i]+dp[i];
总的dp方程就是 : dp[i]=p*1+(1-p)*(1+dp[i-2]+dp[i-1]+dp[i]) ans[i+1][i] = ans[i][i]+dp[i], ans[i+1][i+1] = ans[i+1][i]+dp[i];
Rating
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 171 Accepted Submission(s): 91
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: 4871 4869 4868 4867 4866
大神们都说这题,应该是高斯消元才对,可惜。。屌丝这方面掌握得实在是太渣了。。。还是没能理解。。。
最后还是看了神牛们神一样的DP思路,才终于理解。。。哎。。惭愧。。。
设dp[i]为从i到i+1所需要的步数则有
dp[i]=p*1+(1-p)*(1+dp[i-2]+dp[i-1]+dp[i]) 化简一下得 dp[i]=1+(1-p)/p*(1+dp[i-2]+dp[i-1])
又由已知条件可得 dp[0]=p*1+(1-p)*(1+dp[0]) 即 dp[0]=1/p
dp[1]=p*1+(1-p)*(1+dp[0]]+dp[1]) 即 dp[1]=1/p+(1-p)/p*(1+dp[0])
设ans[i][j]表示从初状态到两个号的分数为i,j的期望。两个号的分数的变化总是[i,i]->[i+1,i]->[i+1,i+1];每次只有一个号的分数在进行变动。
所以有 ans[i+1][i] = ans[i][i]+dp[i], ans[i+1][i+1] = ans[i+1][i]+dp[i];
总的dp方程就是 : dp[i]=p*1+(1-p)*(1+dp[i-2]+dp[i-1]+dp[i]) ans[i+1][i] = ans[i][i]+dp[i], ans[i+1][i+1] = ans[i+1][i]+dp[i];
#include<iostream> #include<cstring> #include<cmath> #include<cstdio> #include<algorithm> using namespace std; double ans[20][20],dp[20]; int main(){ double p; while(cin>>p){ dp[0]=1/p;dp[1]=1+(1-p)/p*(dp[0]+1); for(int i=2;i<=19;i++) dp[i]=1+(1-p)/p*(dp[i-2]+dp[i-1]+1); ans[0][0]=0;ans[1][0]=dp[0];ans[1][1]=ans[1][0]+dp[0]; for(int i=1;i<=19;i++){ ans[i+1][i]=ans[i][i]+dp[i]; ans[i+1][i+1]=ans[i+1][i]+dp[i]; } printf("%.6lf\n",ans[20][19]); } return 0; }
相关文章推荐
- hdu4870 Rating 2014 Multi-University Training Contest 1
- hdu 4870 Rating 2014 Multi-University Training Contest 1
- HDU 4870 Rating 2014 Multi-University Training Contest 1 J题 概率DP+高斯消元
- HDU 4870 Rating (2014 Multi-University Training Contest 1)
- 【比赛总结】2014 Multi-University Training Contest 2
- 2014 Multi-University Training Contest 2
- HDU 4893 Wow! Such Sequence!(2014 Multi-University Training Contest 3)
- 2014 Multi-University Training Contest 5 HDOJ 4911 Inversion
- 2014 Multi-University Training Contest 5 1010 Matrix multiplication 涨姿势系列
- hdu 4937 Lucky Number 2014 Multi-University Training Contest 7
- HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
- hdu 4925 Apple Tree(2014 Multi-University Training Contest 6)
- hdu 4968 Improving the GPA--2014 Multi-University Training Contest 9
- hdu 4973 A simple simulation problem 线段树 2014 Multi-University Training Contest 10-1003
- 2014 Multi-University Training Contest 9 -- 组队选拔赛三
- hdu4864 Task 2014 Multi-University Training Contest 1
- hdu 4864 Task---2014 Multi-University Training Contest 1
- 【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection
- 2014 Multi-University Training Contest 2 ZCC loves cards
- 【HDU 2014 Multi-University Training Contest 1 1002】/【HDU 4862】Jump