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. C#的c/s做出开灯关灯计算?

    static void light(Boolean[] lights,int n) {     if (n <= 1 || lights.Length<5) return;     for ...

  2. 【Spark亚太研究院系列丛书】Spark实战高手之路-第一章 构建Spark集群(第五步)(2)

    把下载下来的"hadoop-2.2.0.tar.gz"复制到"/usr/local/hadoop/"文件夹下并解压: 改动系统配置文件,改动~/.bashrc文 ...

  3. Visual Studio Tips: How to change project namespace

    /* Author: Jiangong SUN */ If you want to modify a project's namespace and its physical container na ...

  4. 原创游戏,金庸群侠传X 0.5公布

    首先说一下背景,我个人从小特别爱玩游戏,对小时候一款游戏<金庸群侠传>DOS版更是情有独钟,自己工作以后,利用业余时间自己整了一个原创的改编版丢网上(找图片.音乐.写剧情更是虐心之极,耗时 ...

  5. Sencha Architect 2 的使用

    俗话说的好, 工欲善其事必先利其器, 用Sencha开发的语言, 自己可能不太熟悉, 写出来很麻烦, 于是给大家介绍一个工具. 启动程序第一个界面: 单击第一个Go按钮, 创建一个项目.进入以后, 单 ...

  6. leetcode dfs Validate Binary Search Tree

    Validate Binary Search Tree Total Accepted: 23828 Total Submissions: 91943My Submissions Given a bin ...

  7. 高性能 Socket 组件 HP-Socket v3.2.1-RC2 公布

    HP-Socket 是一套通用的高性能 TCP/UDP Socket 组件,包括服务端组件.client组件和 Agent 组件,广泛适用于各种不同应用场景的 TCP/UDP 通信系统,提供 C/C+ ...

  8. Android研究之手PullToRefresh(ListView GridView 下拉刷新)使用具体解释

     群里一哥们今天聊天偶然提到这个git hub上的控件:pull-to-refresh ,有兴趣的看下,样例中的功能极其强大,支持非常多控件.本篇博客具体给大家介绍下ListView和GridVi ...

  9. 使用 WPF 创建预加载控件

    Introduction At the time when WPF applications do a very long process like getting response from a w ...

  10. yum使用总结(转)

    安装一个软件时yum -y install httpd安装多个相类似的软件时yum -y install httpd*安装多个非类似软件时yum -y install httpd php php-gd ...