你要去发一个包裹...
到那里发现每个柜台都有一个人在办业务 但是没有其他人在等待
第i个柜台办理一个人的业务需要的时间由一个概率分布函数给出
职员处理一个客户的时间服从指数分布
并且已知你到达那里的时候每个柜台已经办了多久
现在需要求出从此刻开始直到寄完包裹所需的时间的期望
en.wikipedia.org/wiki/exponential_distribution
1/∑k是期望的等待时间
到第i个柜台的概率是 k_i / ∑k 然后期望时间是1/k_i
所以就是 ∑(i=1..n) k_i/∑k * 1/k_i = n / ∑k
加上前面的1/∑k就是(n+1)/∑k了
Delivery
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 77 Accepted Submission(s): 48
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
2
2
0.5 0.4
2 3
3
0.1 0.1 0.1
3 2 5
Sample Output
Case #1: 3.333333
Case #2: 13.333333
Source
2014 ACM/ICPC Asia Regional Beijing Online
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
double a,b,s;
int main()
{
int re ; cin>>re; int ca=1;
while(re--)
{
int n;
cin>>n;
s=0;
for(int i=0;i<n;i++) scanf("%lf",&a), s+=a;
for(int i=0;i<n;i++) scanf("%lf",&a);
printf("Case #%d: %.6f\n", ca++, (n+1)/s);
}
return 0;
}