hdu 5035 Delivery(北京网络赛)

本文探讨了一个关于邮包送达的问题,具体来说,Matt需要将一个包裹送到Ted手中,在邮局遇到N位正在为当前顾客服务的职员,每位职员的服务时间服从特定的指数分布,通过给定的职员效率和已服务时间,计算Matt完成邮寄所需的平均等待时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Delivery

                                                            Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
                                                                                           Total Submission(s): 41    Accepted Submission(s): 21


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 ti for clerk i is a random variable satisfying distribution p(ti = t) = kie^(-kit) where e represents the base of natural logarithm and ki represents the efficiency of clerk i. Besides, accroding to the bulletin board, Matt can know the time ci 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 ki(0<=ki<=1) indicates the efficiency of clerk i.

The third line contains N integers. The i-th integer indicates the time ci(0<=ci<=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
 

推出公式就好了,c没用。
代码:
//453ms
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n;
        double ks=0;
        double x;
        int c;
        scanf("%d",&n);
        for(int j=1;j<=n;j++)
        {
            scanf("%lf",&x);
            ks+=x;
        }
        for(int j=1;j<=n;j++)
        scanf("%d",&c);
        printf("Case #%d: ",i);
        printf("%.6f\n",(n+1)*1.0/ks);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值