博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 4870
阅读量:5150 次
发布时间:2019-06-13

本文共 4410 字,大约阅读时间需要 14 分钟。

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:            
 
设e[x1][y1] (x1 >= y1) 为 从x1 y1出发到终点0 0 的期望步数
可以推出e[x1][y1] = (1 -p) * e[x1][y1 - 2] + p * e[x1][y1 + 1] 
推出n 条方程高斯消元即可
 
1 #include 
2 #include
3 #include
4 #include
5 #include
6 7 8 using namespace std; 9 10 #define read() freopen("sw.in", "r", stdin)11 12 const double eps = 1e-9;13 const int MAX = 305;14 double p;15 double a[MAX][MAX];16 int id[25][25];17 int len = 0;18 19 void init() {20 memset(id, -1 ,sizeof(id));21 for (int i = 0; i < 20; ++i) {22 for (int j = 0; j <= i; ++j) {23 id[i][j] = len++;24 }25 }26 //printf("len = %d\n", len);27 28 }29 30 void solve( int &n) {31 int r;32 for (int i = 0; i < n; ++i) {33 r = i;34 for (int j = i + 1; j < n; ++j) {35 if (fabs(a[j][i]) > fabs(a[r][i])) r = j;36 }37 if (r != i) for (int j = 0; j <= n; ++j) swap(a[r][j], a[i][j]);38 39 for (int j = n; j >= i; --j) {40 for (int k = i + 1; k < n; ++k) {41 a[k][j] -= a[k][i] / a[i][i] * a[i][j];42 }43 }44 }45 46 for (int i = n - 1; i >= 0; --i) {47 for (int j = i + 1; j < n; ++j) {48 a[i][n] -= a[j][n] * a[i][j];49 }50 a[i][n] /= a[i][i];51 }52 53 //for (int i = 0; i < n; ++i)54 printf("%.6f\n", a[0][n]);55 }56 int main()57 {58 // read();59 init();60 while (~scanf("%lf", &p)) {61 memset(a, 0, sizeof(a));62 //cout << p << endl;63 int u, v;64 for (int i = 0; i < 20; ++i) {65 for (int j = 0; j < i; ++j) {66 u = id[i][j];67 68 a[ u ][ u ] = 1;69 a[ u ][ len ] = 1;70 v = id[i][ max(0, j - 2)];71 a[u][v] -= (1.0 - p);72 v = id[i][j + 1];73 a[ u ][ v ] -= p;74 75 76 }77 u = id[i][i];78 a[ u ][ u ] = 1;79 a[ u ][len] = 1;80 v = id[i][ max(0, i - 2) ];81 a[ u ][ v ] -= 1 - p;82 v = id[i + 1][ i ];83 a[ u] [v ] -= p;84 85 }86 87 solve( len);88 89 90 }91 //cout << "Hello world!" << endl;92 return 0;93 }
View Code

 

 

转载于:https://www.cnblogs.com/hyxsolitude/p/3863383.html

你可能感兴趣的文章
设计模式《JAVA与模式》之访问者模式
查看>>
Timer-triggered memory-to-memory DMA transfer demonstrator
查看>>
《架构之美》阅读笔记六
查看>>
boa web服务器
查看>>
将博客搬至CSDN
查看>>
AngularJS ng-model在ng-if里面无效
查看>>
今天2019年5月,21点58分
查看>>
JavaScript_几种创建对象(2017-07-04)
查看>>
类的初始化
查看>>
centos 7 install eclipse cdt and use github
查看>>
android自定义键盘光标不显示解决方法
查看>>
第一章 大型网站架构演化
查看>>
java基础<迷你DVD系统>
查看>>
NO.6LINUX基本命令
查看>>
Ubuntu查找通过apt命令已安装软件
查看>>
关于GC和析构函数的一个趣题
查看>>
跨域问题整理
查看>>
[Linux]文件浏览
查看>>
Sybase 存储过程中IF的用法
查看>>
EasyUI, Dialog 在框架页(ifrmae)的Top页面弹出时,拖拽Dialog边缘(以改变窗口大小),UI界面被卡死的解决办法...
查看>>