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. 《C# 6.0 本质论》 阅读笔记

    <C# 6.0 本质论> 阅读笔记   阅读笔记不是讲述这本书的内容,只是提取了其中一部分我认为比较重要或者还没有掌握的知识,所以如果有错误或者模糊之处,请指正,谢谢! 对于C# 6.0才 ...

  2. poj 3090 &amp;&amp; poj 2478(法雷级数,欧拉函数)

    http://poj.org/problem?id=3090 法雷级数 法雷级数的递推公式非常easy:f[1] = 2; f[i] = f[i-1]+phi[i]. 该题是法雷级数的变形吧,答案是2 ...

  3. 从2月14号開始,上传AppStore会碰到:Failed to locate or generate matching signing assets

    从2月14号開始,上传AppStore时可能会碰到这个问题: Failed to locate or generate matching signing assets Xcode attempted ...

  4. 解析UML九种图

            UML作为设计工具,重在实践上,而这就离不开九种图了.绘图是在看完视频以后进行的,刚開始绘图的时候脑袋懵懵的,不知道该从哪下手,于是就在绘图之前再次的学习了一下这九种图和四种关系.理了 ...

  5. 6.6 random--伪随机数的生成

    本模块提供了生成要求安全度不高的随机数.假设须要更高安全的随机数产生.须要使用os.urandom()或者SystmeRandom模块. random.seed(a=None, version=2) ...

  6. node.js中的require

    初初接触node.js,印象最深刻的就是开头密密麻麻的require了. 这是什么东西? 其实也没啥大惊小怪的.require就是为了引用别的js文件,利于模块化编程,重用.以及避免过多代码挤在同一个 ...

  7. 02、监听key是否正确

    SDKInitializer其实是有两个action,第三个SDK_BROADTCAST_INTENT_EXTRA_INFO_KEY_ERROR_CODE虽然是一个常量但是它不是action.第二个a ...

  8. java网络编程UDP

    图片来自网络 [发送端] import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSoc ...

  9. Linux基础命令第二波

    第1章 Linux启动过程 开机自检(BIOS)##硬件检查 MBR引导 GRUB菜单(选择不同的内核) 加载内核 运行init进程(Linux系统里面第一个进程) 读取/etc/inittab配置文 ...

  10. E20170618-hm

    sentinel   n. 岗哨,哨兵; node   n. 节点; (计算机网络的) 节点; [医] 结节; 植物的节; traverse  n. 穿过; 横贯,横切; 横木; [建] 横梁; vt ...