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. Codeforces Round #256 (Div. 2) C. Painting Fence 或搜索DP

    C. Painting Fence time limit per test 1 second memory limit per test 512 megabytes input standard in ...

  2. Leet code —Jump Game

    问题叙述性说明: Given an array of non-negative integers, you are initially positioned at the first index of ...

  3. Linux下的下载工具介绍----aria2

    ariac 项目地址:http://aria2.sourceforge.net/ 下载地址:http://sourceforge.net/projects/aria2/files/stable/ari ...

  4. Swift难点-继承中的构造规则实例具体解释

    关于继承中的构造规则是一个难点. 假设有问题,请留言问我. 我的Swift新手教程专栏 http://blog.csdn.net/column/details/swfitexperience.html ...

  5. hdu 1395 2^x mod n = 1 暴力过~~最好学下欧拉定理~~~

    2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  6. STL algorithm算法minmax,minmax_element(36)

    minmax原型: std::minmax C++11 C++14 default (1) template <class T> pair <const T&,const T ...

  7. iOS8互动的新通知

    iOS8一旦远程通知想必大家都很熟悉.不要做过多的描述在这里,直接推出iOS8交互式远程通知. 再看互动的通知电话,显示的形式                  如今来看一下详细实现方式 一.通过调用 ...

  8. ffmpeg架构和解码流程分析

    转 一,ffmpeg架构 1. 简介 FFmpeg是一个集录制.转换.音/视频编码解码功能为一体的完整的开源解决方案.FFmpeg的 开发是基于Linux操作系统,但是可以在大多数操作系统中编译和使用 ...

  9. PHP扩展memcache模

    研究yii当配套部件,发现自己PHP甚至不支持memcache该模块,于是,我就展开位. 本机环境:win8.1 开发环境:php 5.5  第一步:先把所需的文件包下载全然,我已经打包好,这里能够下 ...

  10. 传智播客成都校园php纪律指控

    继传智播客成都校区php第一期班圆满开班,说明php的火爆一点儿也不亚于java! 经传智播客商讨决定,传智播客成都校区php学科收费标准例如以下: 採用下面不论什么一种方式都能够享受优惠价: 一.自 ...