船的初始位置随机,要求期望。
那么船从河上正好往东岸赶的几率是1/2,往西岸去再回来的几率是1/2
#include<bits/stdc++.h>
#define CPY(A,B)memcpy(A,B,sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fLL;
const double EPS=1e-8;
const double OO=1e20;
const double PI=acos (-1.0);
int dx[]= {0,1,0,-1};
int dy[]= {1,0,-1,0};
int gcd (const LL &a,const LL &b) {return b==0?a:gcd (b,a%b);}
using namespace std;
int main() {
int n,cas=0; double D,T;
while (~scanf ("%d%lf",&n,&D) &&(n+D)) {
double p,L,v,Ls=0; T=0;
while (n--) {
scanf ("%lf%lf%lf",&p,&L,&v);
T+=2.0*L/v;
Ls+=L;
}
T+= (D-Ls);
printf ("Case %d: %.3f\n",++cas,T);
puts ("");
}
return 0;
}