![]() | ||||||||||
| ||||||||||
| ||||||||||
DeliveryTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 234 Accepted Submission(s): 158
Problem Description
Today, Matt goes to delivery a package to Ted. When he arrives at the post office, he finds there are N clerks numbered from 1 to N. All the clerks are busy but there is no one else waiting in line. Matt will go to the first clerk who has finished the service for the current customer. The service time t
i for clerk i is a random variable satisfying distribution p(t
i = t) = k
ie^(-k
it) where e represents the base of natural logarithm and k
i represents the efficiency of clerk i. Besides, accroding to the bulletin board, Matt can know the time c
i which clerk i has already spent on the current customer. Matt wants to know the expected time he needs to wait until finishing his posting given current circumstances.
Input
The first line of the input contains an integer T,denoting the number of testcases. Then T test cases follow.
For each test case, the first line contains one integer:N(1<=N<=1000) The second line contains N real numbers. The i-th real number k i(0<=k i<=1) indicates the efficiency of clerk i. The third line contains N integers. The i-th integer indicates the time c i(0<=c i<=1000) which clerk i has already spent on the current customer.
Output
For each test case, output one line "Case #x: y", where x is the case number (starting from 1), y is the answer which should be rounded to 6 decimal places.
Sample Input
Sample Output
Source
Recommend
| ||||||||||
|
题目大意:
Matt去发快递,快递点有N个职员,职员处理一个客户的时间服从指数分布: f(t)=λe−λt ,其中的参数 λ 为职员的效率,现在给出每个职员的效率,同时给了一个场景:现在每个职员都有且只有客户在服务中,此人还从信息牌得知了每个职员已经为当前客户服务了c时间,题目中也给出了,一旦有客户被服务完毕,则这个人就立刻去接受服务。问在此场景下,这个人发快递需要的时间的期望是多少?
解析:
首先几何分布的一些性质:
一个几何分布的概率密度函数是:
f(xλ)={λe−λx0,x≥0,,x<0.
概率分布函数为:
F(xλ)={1−e−λx0,x≥0,,x<0.
指数分布具有“无记忆性”,如果一个随机变量呈指数分布,它的条件概率遵循:
P(T>s+t|T>t)=P(T>s)for all s,t≥0.
然后分析该题目,利用指数分布的无记忆性可以知道,如 t0 时刻,第 i 个职员第一个服务完当前客户,那么接着就会服务Matt,然后服务完Matt。这个过程时间的期望就是我们要求的结果。
因此我们要求的就是:
∑i=1N∫+∞0(E(Xi)+x)λie−λi∏j≠i(∫+∞xf(x:λj)dx)dx
解释下上面长长的式子:
第 i 个职员t时刻接待Matt的概率为 λie−λi (此时第i个结束时间为t的概率),乘上 ∏j≠i∫+∞xf(x:λj)dx (其它职员结束时间大于t的概率));而这种情况下的时间为 (E(Xi)+t)
t可以从 0 一直取到 +∞ ,把所有的职员按照上面的情况分析一边,就有了上面的那个式子了。由于指数分布的无记忆性,可以知道题目中给的已服务时间实际上是没有用的……
剩下的就是一些化简计算了,
∑k=1N∫+∞0(E(Xi)+x)λie−λi∏j≠i(∫+∞xf(x:λj)dx)dx=∑k=1N∫+∞0(E(Xi)+x)λie−λi∏j≠ieλjdx=∑k=1N∫+∞0(E(Xi)+x)λie−∑Ni=1λidx=∑k=1N(1∑Ni=1λi+λi(∑Ni=1λi)2)=N+1∑Ni=1λi
有了这个公式代码应该是不难写,不过要注意这题数据比较多,cin或许或TLE~
#include <stdio.h>
double ans, x;
int main(){
int T;
scanf("%d", &T);
for(int tt=1; tt<=T; tt++){
int n;
scanf("%d", &n);
ans = 0;
for(int i=0; i<n; i++){
scanf("%lf", &x);
ans += x;
}
for(int i=0; i<n; i++) scanf("%*d");
printf("Case #%d: %.6lf\n", tt, (n+1)/ans);
}
return 0;
}