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. CheckBoxList的操作查询是否被选中设置或者得到

    在项目中我们可能会经常遇到一收集多选信息的情况,比如做注册的时候要收集个人爱好,那时候大家第一个想到的肯定是CheckBoxList.那我们怎么来获取到CheckBoxList的值并且存入数据库呢?? ...

  2. Oracle SQL Lesson (1) - 使用SQL Select语句获取数据

    第一节课: 启动数据库并且使用特定用户连接:su - oracle; 启动sqlplus并且使用sys连接:conn / as sysdba; 启动数据库:startup; 解锁用户:alter us ...

  3. hdu1005 Number Sequence(寻找循环节)

    主题链接: pid=1005">huangjing 题意: 就是给了一个公式,然后求出第n项是多少... 思路: 题目中n的范围实在是太大,所以肯定直接递推肯定会超时,所以想到的是暴力 ...

  4. Apache介绍

    怎样使用Apache许可证         若用户须要应用Apache许可证,请将下面演示样例使用适当的注视方法包括在作品源文件里,将括号"[]"中的字段以用户自身的区分信息来替换 ...

  5. Storm On YARN带来的好处

    1)弹性计算资源     将storm执行在yarn上后.Storm能够与其它计算框架(如mapreduce)共享整个集群的资源.这样当Storm负载骤增时,可动态为它添加计算资源. 负载减小时,能够 ...

  6. spring 重定向以及转发 乱码问题解决

    1.spring 转发 request.setAttribute("id", id); request.setAttribute("name",name); r ...

  7. 查看文章strncpy()功能更好的文章

    strncpy()功能 原型:extern char *strncpy(char *dest, char *src, int n);    使用方法:#include <string.h> ...

  8. python 凸包(经纬度) + 面积[近似]

    def cross(A,B): return A[0] * B[1] - A[1] * B[0] def vectorMinus( a , b): return ( (a[0] - b[0] )*10 ...

  9. wpf做的3d滑动gallery

    原文:wpf做的3d滑动gallery wpf做的3d滑动gallery 随着iphone\ipad的流行及热捧,现在做移动产品不管是什么平台的,领导总想做成像ios系统的样子.自从微软发布了wind ...

  10. C# The process cannot access the file because it is being used by another process

    C# The process cannot access the file because it is being used by another process   The process cann ...