AIZU2303marathon match 概率
2015-08-25 09:23
344 查看
[code]#include <cstdio> #include <iostream> #include <cstring> #include <cmath> using namespace std; #define LL long long double p[200]; int t[200]; int v[200]; LL C[100][100]; double dp[105][55]; int main(){ int n,m,l; cin >> n >> m >> l; for(int i = 0;i < n;i++){ int x,tt,vv; scanf("%d%d%d",&x,&tt,&vv); p[i] = x / 100.0,t[i] = tt,v[i] = vv; } for(int i = 0;i <= 50;i++){ C[i][0] = 1; C[i][i] = 1; for(int j = 1;j < i;j++){ C[i][j] = C[i-1][j]+C[i-1][j-1]; //cout<<C[i][j] << endl; } } for(int i = 0;i < n;i++){ dp[i][m+1] = 0; for(int j = m;j >= 0;j--){ //休息>j次 dp[i][j] = dp[i][j+1] + C[m][j]*pow(p[i],j)*pow(1-p[i],m-j); //cout << dp[i][j] << endl; } } for(int i = 0;i < n;i++){ double ans = 0; if(v[i] != 0){ for(int j = 0;j <= m;j++){ double ut = l*1.0/v[i] + j*t[i]; double pa = C[m][j]*pow(p[i],j)*pow(1-p[i],m-j); for(int k = 0;k < n;k++){//赢k个人的概率 if(k != i){ if(v[k] == 0){ pa *= 1; continue; } int tim; if(t[k] == 0){ if(l*1.0/v[k] <= ut){ pa *= 0; } else{ pa *= 1; } continue; } tim = floor((ut-(l*1.0/v[k]))/t[k]); while((tim*t[k]+l*1.0/v[k]) <= ut) tim++; if(tim > m){ pa *= 0; } else if(tim < 0){ pa *= 1; }else{ pa *= dp[k][tim]; } } } //printf("%lf\n",pa); ans += pa; } } printf("%.8f\n",ans); } return 0; }
相关文章推荐
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2)
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) B
- 为什么Android每当启动一个新的应用程序时会通过“throw new ZygoteInit.MethodAndArgsCaller(m, argv)”进入ActivityThread的main函数
- Run-Time Check Failure #2 - Stack around the variable 'myTrackbarName' was corrupted.
- 【Linux学习】epoll详解 http://blog.csdn.net/xiajun07061225/article/details/9250579
- Factorial Trailing Zeroes
- HDU 4300 Clairewd’s message(KMP)
- KMP HDOJ 4300 Clairewd's message
- Failed to install metadata only whitespace content allowed before start tag and not \u0
- HDU2389 Rain on your Parade(二分图匹配 ,HK算法 )
- Aizu - 2306 Rabbit Party (DFS图论)
- 文本文件查看命令:cat, tac, more, less, tail, head
- POJ1273——最大流之Edmonds-Karp——Drainage Ditches
- Aizu - 2305 Beautiful Currency (二分 + DFS遍历)
- svn cleanup failed 解决办法
- poj 1995 Raising Modulo Numbers 【快速幂】
- hdu1532 Drainage Ditches
- hdu 1702 ACboy needs your help again!
- 1090. Highest Price in Supply Chain (25) -计层的BFS改进
- 1090. Highest Price in Supply Chain (25) -计层的BFS改进