20141002 【 数论--概率 】 hdoj 5035 Delivery

17 篇文章 0 订阅
9 篇文章 0 订阅

F.A.Q
Hand In Hand
Online Acmers
Forum | Discuss
Statistical Charts
Problem Archive
Realtime Judge Status
Authors Ranklist
 
      C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
Virtual Contests 
    DIY | Web-DIY beta
Recent Contests
BestCoder官方群:385386683 欢迎加入~
寻人启事:2014级新生看过来!

Delivery

Time 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
      
      
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
 

Recommend
hujie   |   We have carefully selected several similar problems for you:   5056  5055  5054  5053  5052 
 

Statistic |  Submit |  Discuss |  Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2014 HDU ACM Team. All Rights Reserved.
Designer & Developer Wang Rongtao LinLe GaoJie GanLu
Total 0.031621(s) query 7, Server time : 2014-10-02 11:40:16, Gzip disabled




题目大意:

Matt去发快递,快递点有N个职员,职员处理一个客户的时间服从指数分布: f(t)=λeλt ,其中的参数 λ 为职员的效率,现在给出每个职员的效率,同时给了一个场景:现在每个职员都有且只有客户在服务中,此人还从信息牌得知了每个职员已经为当前客户服务了c时间,题目中也给出了,一旦有客户被服务完毕,则这个人就立刻去接受服务。问在此场景下,这个人发快递需要的时间的期望是多少?

解析:

首先几何分布的一些性质: 
一个几何分布的概率密度函数是: 

f(xλ)={λeλx0,x0,,x<0.

概率分布函数为: 
F(xλ)={1eλx0,x0,,x<0.

指数分布具有“无记忆性”,如果一个随机变量呈指数分布,它的条件概率遵循: 
P(T>s+t|T>t)=P(T>s)for all s,t0.

然后分析该题目,利用指数分布的无记忆性可以知道,如 t0 时刻,第 i 个职员第一个服务完当前客户,那么接着就会服务Matt,然后服务完Matt。这个过程时间的期望就是我们要求的结果。 
因此我们要求的就是: 
i=1N+0(E(Xi)+x)λieλiji(+xf(x:λj)dx)dx

解释下上面长长的式子: 
i 个职员t时刻接待Matt的概率为 λieλi (此时第i个结束时间为t的概率),乘上 ji+xf(x:λj)dx (其它职员结束时间大于t的概率));而这种情况下的时间为 (E(Xi)+t)  
t可以从 0 一直取到 + ,把所有的职员按照上面的情况分析一边,就有了上面的那个式子了。由于指数分布的无记忆性,可以知道题目中给的已服务时间实际上是没有用的…… 
剩下的就是一些化简计算了, 
k=1N+0(E(Xi)+x)λieλiji(+xf(x:λj)dx)dx=k=1N+0(E(Xi)+x)λieλijieλjdx=k=1N+0(E(Xi)+x)λieNi=1λidx=k=1N(1Ni=1λi+λi(Ni=1λi)2)=N+1Ni=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;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值