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
 
Recommend
We have carefully selected several similar problems for you:  

pid=4896" target="_blank">4896 

pid=4895" target="_blank">4895 4894 4892 

pid=4891" target="_blank">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<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>
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<cnt;row++)
{
maxx=fabs(mat[row][row]);
id=row;
for(i=row+1;i<cnt;i++)//mat[i][cnt]为常数项
{
if(fabs(mat[i][row])>maxx)
{
maxx=fabs(mat[i][row]);
id=i;
}
}
if(maxx<eps)
return false;
if(id!=row)
{
for(i=row;i<=cnt;i++)
swap(mat[row][i],mat[id][i]);
}
for(i=row+1;i<cnt;i++)
{
if(fabs(mat[i][row])<eps)
continue;
var=mat[i][row]/mat[row][row];
for(j=row;j<=cnt;j++)
mat[i][j]-=mat[row][j]*var;
}
}
for(i=cnt-1;i>=0;i--)
{
for(j=i+1;j<cnt;j++)
mat[i][cnt]-=mat[i][j]*mat[j][j];
mat[i][i]=mat[i][cnt]/mat[i][i];
}
return true;
}
int main()
{
int i,j,ptr,base,pp,a,b,c;
double p; for(i=0;i<=20;i++)
for(j=0,base=i*(i+1)/2;j<=i;j++)
mp[i][j]=base+j;
cnt=231;
while(~scanf("%lf",&p))
{
ptr=0;
memset(mat,0,sizeof mat);
for(i=0;i<=20;i++)
{
for(j=0;j<=i;j++)
{
if(i==20)
{
pp=mp[i][j];
mat[ptr][pp]=1;
mat[ptr++][cnt]=0;
continue;
}
a=max(i,j+1);
b=min(i,j+1);
c=max(0,j-2);
mat[ptr][cnt]=1;
pp=mp[i][j];
mat[ptr][pp]+=1;
pp=mp[a][b];
mat[ptr][pp]+=-p;
pp=mp[i][c];
mat[ptr++][pp]+=p-1;
}
}
gauss();
printf("%.8lf\n",mat[0][0]);
}
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

hdu 4870 Rating(可能性DP&amp;高数消除)的更多相关文章

  1. HDU 4870 Rating 概率DP

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

  2. 2014多校第一场J题 || HDU 4870 Rating(DP || 高斯消元)

    题目链接 题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的 ...

  3. hdu 4870 Rating

    题目链接:hdu 4870 这题应该算是概率 dp 吧,刚开始看了好几个博客都一头雾水,总有些细节理不清楚,后来看了 hdu 4870 Rating (概率dp) 这篇博客终于有如醍醐灌顶,就好像是第 ...

  4. HDU 4870 Rating(高斯消元 )

    HDU 4870   Rating 这是前几天多校的题目,高了好久突然听旁边的大神推出来说是可以用高斯消元,一直喊着赶快敲模板,对于从来没有接触过高斯消元的我来说根本就是一头雾水,无赖之下这几天做DP ...

  5. HDU 4870 Rating(概率、期望、推公式) && ZOJ 3415 Zhou Yu

    其实zoj 3415不是应该叫Yu Zhou吗...碰到ZOJ 3415之后用了第二个参考网址的方法去求通项,然后这次碰到4870不会搞.参考了chanme的,然后重新把周瑜跟排名都反复推导(不是推倒 ...

  6. HDU 4870 Rating (2014 Multi-University Training Contest 1)

    Rating Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  7. HDU 4870 Rating (2014 多校联合第一场 J)(概率)

    题意: 一个人有两个TC的账号,一开始两个账号rating都是0,然后每次它会选择里面rating较小的一个账号去打比赛,每次比赛有p的概率+1分,有1-p的概率-2分,当然如果本身是<=2分的 ...

  8. HDU 4870 Rating (高斯消元)

    题目链接  2014 多校1 Problem J 题意  现在有两个账号,初始$rating$都为$0$,现在每次打分比较低的那个,如果进前$200$那么就涨$50$分,否则跌$100$分.   每一 ...

  9. HDU 4870 Rating 高斯消元法

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4870 题意:用两个账号去參加一种比赛,初始状态下两个账号都是零分,每次比赛都用分数低的账号去比赛.有P的概 ...

随机推荐

  1. 域名注册查询接口(API)的说明

    1.域名查询 接口采用HTTP,POST,GET协议: 调用URL:http://panda.www.net.cn/cgi-bin/check.cgi 参数名称:area_domain 值为标准域名, ...

  2. vs2012 它已停止工作 - 解决方案

    最近学习<Windows多媒体编程>本课程, 蛋疼, 学校原来是MFC... 然后安装vs2012.   后来又在几个插件.. 在这个问题. 开业,提示 vs2012 它已停止工作. wa ...

  3. hdu2089不要62(数位dp)

    #include <stdio.h> #include <string.h> ][]; ]; /* dp[i][0] 不含62,4 dp[i][1] 2开头 dp[i][2] ...

  4. RedGate 工具SQLMultiScript1.1

    原文:RedGate 工具SQLMultiScript1.1 RedGate 工具SQLMultiScript1.1 SQLMultiScript是一个脚本分发工具,当你写好了一个SQL脚本之后,你需 ...

  5. [置顶] 利用CXF发布webService的小demo

    其实webService的发布不仅仅只有xfire,今天,给大家介绍一下用CXF发布一个webService的小demo,CXF也是我做webService用的第一个框架... 先将相关的jar引进来 ...

  6. android应用开发--------------看RadioGroup源代码,写相似单选选项卡的集成控件(如底部导航,tab等等)

    博客为 有时个哥 原创.如需转载请标明出处:http://blog.csdn.net/ls703/article/details/46694967 watermark/2/text/aHR0cDovL ...

  7. Nutch+Lucene搜索引擎开发实践

    网络拓扑 图 1 网络拓扑图 安装Java JDK 首先查看系统是否已经安装了其它版本号的JDK,假设有,先要把其它版本号的JDK卸载. 用root用户登录系统. # rpm-qa|grep gcj ...

  8. 使用GDAL图书馆RPC校正问题

    很快就会GDAL库更新1.11版本号之后,在发现之前写RPC像方误差修正模型校准结果特别大(在更新结果之前的版本号和PCI结果一致).所以初步推断是GDAL库的bug,经过各个參数改动发现原来是指定的 ...

  9. 图的创建和遍历(BFS/DFS)

    图的表示方法主要有邻接矩阵和邻接表.其中邻接表最为常用,因此这里便以邻接表为例介绍一下图的创建及遍历方法. 创建图用到的结构有两种:顶点及弧 struct ArcNode { int vertexIn ...

  10. hdu1052 Tian Ji -- The Horse Racing 馋

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1052">http://acm.hdu.edu.cn/showproblem.php ...