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

题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的那个去做,问她最终有一个账号达到1000分需要做的比赛的次数的期望值。

思路 :可以直接用公式推出来用DP做,也可以列出210个方程组用高斯消元去做。

(1)DP1:离散化。因为50,100,1000都是50的倍数,所以就看作1,2,20。这样做起来比较方便。

定义dp[i]为从 i 分数到达i+1分的期望,状态转移方程:

dp[i] = p+(1-p)*(1+dp[i-2]+dp[i-1]+dp[i]); 在前两百名里增加一分,当不在前两百名里的时候,扣两分,要回到 i+1 分就是1+dp[i-2]+dp[i-1]+dp[i].

mp[i][i]表示两个账号都从0分涨到 i 分的期望,所以mp[i+1][i] = mp[i][i]+dp[i], mp[i+1][i+1] = mp[i+1][i]+dp[i];

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h> using namespace std ; double dp[],mp[][] ; int main()
{
double p ;
while(scanf("%lf",&p) != EOF)
{
dp[] = / p ;
dp[] = / p / p ;
for(int i = ; i < ; i++)
dp[i] = + (-p)*(dp[i-]+dp[i-]+)/p ;
for(int i = ; i < ; i++)
{
mp[i+][i] = mp[i][i]+dp[i] ;
mp[i+][i+] = mp[i+][i] + dp[i] ;
}
printf("%.6lf\n",mp[][]) ;
}
return ;
}
 

最新文章

  1. java 入门 第二季1
  2. 【JAVA网络流之URL】
  3. 在Visual Studio中使用MonoTouch开发iOS应用程序
  4. 【BZOJ】【2178】圆的面积并
  5. 爱莲(iLinkIT)的架构与原理
  6. CGAL 介绍
  7. 李洪强漫谈iOS开发[C语言-027]-自增与自减运算符
  8. 15--Box2D使用(一、创建物理世界)
  9. 摩根斯坦利 - 2016年09月8日 面试题 - HashMap
  10. How to change current process to background process
  11. FileProvider解决FileUriExposedException
  12. 机器视觉----LBP
  13. RGBA 和 opacity的区别
  14. 51Nod 1293 球与切换器 DP分类
  15. SpringBoot中出现的错误
  16. java从文件中读取json
  17. python--批量下载豆瓣图片之升级版本
  18. springMVC第二天——高级参数绑定与其它特性
  19. (1)vue点击图片预览(可旋转、翻转、缩放、上下切换、键盘操作)
  20. pygame-KidsCanCode系列jumpy-part4-弹跳

热门文章

  1. wireshark http过程
  2. Java-note-字符串连接
  3. [apkAnalyzer] 查看APK包名
  4. Windows 窗体—— 键盘输入工作原理
  5. 定位程序问题的方法 -- clwu
  6. Todolist
  7. sqlserver 中的GUID 全局唯一标识 -摘自网络
  8. 深入浅出Zookeeper
  9. javascript中sleep等待实现
  10. uva 1356 Bridge ( 辛普森积分 )