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. 【Cocos2dx游戏开发】CCNotificationCenter传递消息和数据

    在开发游戏的时候我们经常需要在层与层之间.场景与场景之间传递数据和消息,Cocos2dx框架应用观察者模式为我们封装了一个CCNotificationCenter类,也叫消息通知中心,它也是一个单例类 ...

  2. zTree初体验(一)——小试牛刀

    zTree 是一个依靠 jQuery 实现的多功能 "树插件".优异的性能.灵活的配置.多种功能的组合是 zTree 最大长处. --zTree官网 zTree v3.0 将核心代 ...

  3. C/C++ 答疑解问

    1. sizeof(string)的大小 string属于类,类的大小就是类中成员变量(非静态)加上指向虚函数表的指针以及指向虚基类表的指针加起来的和.因为string是一个模板类,受具体的实现来决定 ...

  4. C++中的继承与虚函数各种概念

    虚继承与一般继承 虚继承和一般的继承不同,一般的继承,在目前大多数的C++编译器实现的对象模型中,派生类对象会直接包含基类对象的字段.而虚继承的情况,派生类对象不会直接包含基类对象的字段,而是通过一个 ...

  5. HDU 5446 CRT+Lucas+快速乘

    Unknown Treasure Problem Description On the way to the next secret treasure hiding place, the mathem ...

  6. linux 统计 文件夹信息

    ls -lR|grep "^-"|wc -l Linux 统计某个字符串出现的次数 - ywl925 - 博客园 https://www.cnblogs.com/ywl925/p/ ...

  7. nova service-list for juno kilo,liberty openstack

  8. E20170629-hm

    enqueue  [计] 入队,排队; dequeue  [计]  出列; rear  n. 后部,背面,背后; 臀部; (舰队或军队的) 后方,后尾,殿后部队; 〈英口〉厕所; ring buffe ...

  9. TextMeshPro 图片字Sprite

      生成 需要一个资源  右键生成 调整位置  放在目录  使用 <sprite="NumDamage" index=1><sprite="NumDam ...

  10. Akka源码分析-深入ActorRef&ActorPath

    上一节我们深入讨论了ActorRef等相关的概念及其关系,但ActorRef和ActorPath的关系还需要再加以分析说明.其实还是官网说的比较清楚. “A path in an actor syst ...