https://www.luogu.com.cn/problem/UVA12230
期望的线性性质
设初始答案 A,为全走陆地的时间 D,则每次输入时去河的长度 L,加上渡河期望时间 2* L/v
#include<iostream> #include<cstring> #include<algorithm> #include<set> using namespace std; int n,D; signed main() { int cas=0; while(cin>>n>>D,n||D){ double ans=D; for(int i=1;i<=n;i++){ int p,L,v; cin>>p>>L>>v; ans-=L; ans+=(double)2*L/v; } printf("Case %d: %.3lf\n\n",++cas,ans); } }
标签:int,double,Rivers,uva12230,ans,Crossing,include From: https://www.cnblogs.com/towboa/p/17300461.html