Rating

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 348    Accepted Submission(s): 217
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:  4871 4868 4867 4866 4865 
 
设e[x1][y1] (x1 >= y1) 为 从x1 y1出发到终点0 0 的期望步数
可以推出e[x1][y1] = (1 -p) * e[x1][y1 - 2] + p * e[x1][y1 + 1] 
推出n 条方程高斯消元即可
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; #define read() freopen("sw.in", "r", stdin) const double eps = 1e-;
const int MAX = ;
double p;
double a[MAX][MAX];
int id[][];
int len = ; void init() {
memset(id, - ,sizeof(id));
for (int i = ; i < ; ++i) {
for (int j = ; j <= i; ++j) {
id[i][j] = len++;
}
}
//printf("len = %d\n", len); } void solve( int &n) {
int r;
for (int i = ; i < n; ++i) {
r = i;
for (int j = i + ; j < n; ++j) {
if (fabs(a[j][i]) > fabs(a[r][i])) r = j;
}
if (r != i) for (int j = ; j <= n; ++j) swap(a[r][j], a[i][j]); for (int j = n; j >= i; --j) {
for (int k = i + ; k < n; ++k) {
a[k][j] -= a[k][i] / a[i][i] * a[i][j];
}
}
} for (int i = n - ; i >= ; --i) {
for (int j = i + ; j < n; ++j) {
a[i][n] -= a[j][n] * a[i][j];
}
a[i][n] /= a[i][i];
} //for (int i = 0; i < n; ++i)
printf("%.6f\n", a[][n]);
}
int main()
{
// read();
init();
while (~scanf("%lf", &p)) {
memset(a, , sizeof(a));
//cout << p << endl;
int u, v;
for (int i = ; i < ; ++i) {
for (int j = ; j < i; ++j) {
u = id[i][j]; a[ u ][ u ] = ;
a[ u ][ len ] = ;
v = id[i][ max(, j - )];
a[u][v] -= (1.0 - p);
v = id[i][j + ];
a[ u ][ v ] -= p; }
u = id[i][i];
a[ u ][ u ] = ;
a[ u ][len] = ;
v = id[i][ max(, i - ) ];
a[ u ][ v ] -= - p;
v = id[i + ][ i ];
a[ u] [v ] -= p; } solve( len); }
//cout << "Hello world!" << endl;
return ;
}
 

hdu 4870的更多相关文章

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

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

  2. HDU 4870 Rating 概率DP

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

  3. hdu 4870 Rating

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

  4. HDU 4870 Rating(高斯消元 )

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

  5. HDU 4870 Rating 高斯消元法

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

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

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

  7. 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 ...

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

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

  9. hdu 4870 Rating(可能性DP&amp;高数消除)

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

  10. HDU 4870 Rating (高斯消元)

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

随机推荐

  1. 安装 openCV 2.4.10

    近期试验了一下 ubuntu 12.06 (x86) 安装.openCV 安装脚本 最好的文章是 https://help.ubuntu.com/community/OpenCV. 它提供一个脚本( ...

  2. Centos 7 nginx-1.12.0 配置学习(一)

    [root@bogon nginx]# vim nginx.conf #user nobody; #运行用户 worker_processes ; #启动进程,通常设置成和cpu核心数相等 #全局错误 ...

  3. Java设计模式菜鸟系列(一)策略模式建模与实现

    转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39721563 今天開始咱们来谈谈Java设计模式. 这里会结合uml图形来解说,有对uml ...

  4. 分布式数据库中间件DDM的实现原理

    随着数据量不断增大,传统的架构模式难以解决业务量不断增长所带来的问题,特别是在业务成线性.甚至指数级上升的情况.此时我们不得不通过水平扩展,把数据库放到不同服务器上来解决问题,也就是我们说的数据库中间 ...

  5. 500万url的es 批删除

    bash  循环 算术计算 读写文件 [root@hadoop2 ~]# sh looh.sh1234LIZ1 2 3 4 0 1 2 3 4 5 6 7 8 9 10 0games:x:12:100 ...

  6. Jsp内置对象和EL隐藏(内置)对象

      JSP中的内置对象一共有九个, 由于有的不太常用, 所以总是记不住, 从Sun公司的网站上找到的PDF文档, 把这一部分放在这里, 以备随时查用:     JSP九个内置对象: Implicit ...

  7. B1072 [SCOI2007]排列perm 状压dp

    很简单的状压dp,但是有一个事,就是...我数组开大了一点,然后每次memset就会T,然后开小就好了!!!震惊!以后小心点这个问题. 题干: Description 给一个数字串s和正整数d, 统计 ...

  8. 杂项:E-Learning

    ylbtech-杂项:E-Learning 1.返回顶部 1. E-Learning:英文全称为(Electronic Learning),中文译作“数字(化)学习”.“电子(化)学习”.“网络(化) ...

  9. 用回调函数创建一个XMLHttpRequest,并从一个TXT文件中检索数据。

    <script> var xmlhttp; function loadXMLDoc(url,soyo) { if (window.XMLHttpRequest) {// IE7+, Fir ...

  10. 利用Spinnaker创建持续交付流水线

    在Pivotal Container Service (PKS)上部署软件的方法多种多样,本文重点介绍如何使用Spinnaker在PKS(或任何Kubernetes群集)上进行持续交付. Pivota ...