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