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 ;
}
 

最新文章

  1. texrecon进行纹理映射
  2. Hadoop CDH5 集群管理
  3. Python强化训练笔记(一)——在列表,字典,集合中筛选数据
  4. 2D空间中求一点是否在多边形内
  5. 关于FlexPaper 2.1.2版本 二次开发 Logo 、打印、搜索、缩略图、添加按钮、js交互、右键菜单、书签等相关问题
  6. Android属性动画完全解析(中)
  7. Delphi基本图像处理代码
  8. maven管理的项目出现Error configuring application listener of class org.springframework.web.context.ContextL
  9. 深入浅出Java 重定向和请求转发的区别
  10. C#窗体实现文件拖拽功能
  11. Android Studio简单设置(转)
  12. DAS,NAS,SAN在数据库存储上的应用
  13. Zookeeper 快速入门(上)
  14. [Swift]LeetCode938. 二叉搜索树的范围和 | Range Sum of BST
  15. 关于NGUI Shader 和 Draw Call的优化 &amp; 模糊shader
  16. DevExpress v18.1新版亮点——Reporting篇(三)
  17. MVC-READ4
  18. 【线段树】Gym - 101201J - Shopping
  19. HDU 1695 GCD (欧拉函数,容斥原理)
  20. python startswith与endswith

热门文章

  1. leetCode(49):Count Primes
  2. LeetCode 824. Goat Latin (山羊拉丁文)
  3. LeetCode 172. Factorial Trailing Zeroes (阶乘末尾零的数量)
  4. Localhost 回环IP 127.0.0.1
  5. 如何删除 mac 系统信息下的安装记录
  6. coffeescript的上下文
  7. jquery操作删除元素
  8. YTU 2732:3798-Abs Problem
  9. 洛谷P3402 最长公共子序列
  10. PCB Genesis脚本 C#调用Python