Miku


由期望的线性可知,这个人经过每一条河的时候船可以在任何一个地方,并且概率相等

那么来讲,这个人最好需要\(L/v\)最差\(3*L/v\),平均\(2*L/V\)

然后就行了

#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,d;
int p,l,v;
double sum;
double ans;
int main(){
	for(int i=1;1;++i){
		scanf("%d%d",&n,&d);
		ans=0.0;
		sum=0;
		if(n==0&&n==d)
		return 0;
		for(int j=1;j<=n;++j){
			scanf("%d%d%d",&p,&l,&v);
			ans+=l*2.0/v;
			sum+=l;	
		}	
		ans+=(double)d-sum;
		printf("Case %d: %.3lf\n\n",i,ans);
	}
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-06-20
  • 2021-08-20
  • 2021-11-30
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2021-06-05
  • 2021-05-17
  • 2021-12-22
  • 2022-12-23
相关资源
相似解决方案