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. SyntaxError:identifier starts immediately after numeric literal

    1.错误描写叙述 2.错误原因 因为在改动方法传參的过程,须要传个id,可是这个id是字符串类型,传入的是数值型 3.解决的方法 在传參时,须要加入"",变成字符串类型 User. ...

  2. 创业公司十分钟简单搭建GIT私有库

    欢迎关注老码农的微信公共账号,与CSDN博客同步 一.背景 小公司.协同开发的人不多,建gitlab比較麻烦,仅仅须要在Server端建立一个简单的git共享库就OK. 二.建立仓库 Server端: ...

  3. ERROR (ConnectionError): HTTPConnectionPool (Caused by &lt;class &#39;socket.error&#39;&gt;: [Errno 111] Connecti

    感谢朋友支持本博客.欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免.欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  4. HDFS01

    ==============NameNode============== 管理文件系统的命名空间 记录每个文件数据在各个DataNode上的位置和副本信息 协调客户端对文件的访问 NameNode文件 ...

  5. http协议的MP4文件播放问题的分析

    现在手上有两个链接 (1) http://202.108.16.173/cctv/video/8C/35/EB/E8/8C35EBE84E7B483C8741CF9A60154993/gphone/4 ...

  6. codeforces round #415 div2

    由于下午硬钢树套树和大力颓废就没补完 C:我傻逼比赛时没做出来...就是排个序然后算贡献 #include<bits/stdc++.h> using namespace std; type ...

  7. 03-vue实例生命周期和vue-resource

    vue实例的生命周期 什么是生命周期:从Vue实例创建.运行.到销毁期间,总是伴随着各种各样的事件,这些事件,统称为生命周期! 生命周期钩子:就是生命周期事件的别名而已: 生命周期钩子 = 生命周期函 ...

  8. php 静态属性和静态变量

  9. weak看iOS面试

    2013年 面试官:代理用weak还是strong? 我 :weak . 面试官:明天来上班吧 2014年 面试官:代理为什么用weak不用strong? 我 : 用strong会造成循环引用. 面试 ...

  10. Croppic插件使用介绍-asp.net

    具体的参数使用和基本使用方式请看:http://www.uedsc.com/croppic-api.html 需要说明的几点: 1.支持两种上传方式: (1)先将原图上传至服务器,然后再次将切图信息传 ...