Codeforces Round #364 (Div. 2), problem: (D) As Fast As Possible

题意:
一群人去一个地方,只有一辆车,已知人的速度,路程,车的速度,人数和每一次车的最大载客量,且每个人只能坐一次车。求最短到达时间。
题解:
人的行程分为走路和坐车,当且仅当走路的人和最后一批坐车的人同时到达时,时间最短,按照对称性,可以知道每一批人坐车和走路的时间都是一样的,所以最后是推公式得到坐车和走路的时间。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
typedef unsigned long long ull;
#define pr(x) cout << #x << ": " << x << "  "
#define pl(x) cout << #x << ": " << x << endl;
#define pri(a) printf("%d\n",(a))
#define xx first
#define yy second
#define sa(n) scanf("%d", &(n))
#define sal(n) scanf("%lld", &(n))
#define sai(n) scanf("%I64d", &(n))
#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++)

int main(){
   int n,k;
   double l,v1,v2;
   cin>>n>>l>>v1>>v2>>k;
   int step;
   if(n%k==0){step = n/k;}
   else{step = n/k+1;}
   double a=(v1+v2)*l/(v1+v2+2*(step-1)*v1);
   double ans = a/v2+(l-a)/v1;
   printf("%.10f\n",ans);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值