UVA 12230 Crossing Rivers

#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int id=1;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
#endif // ONLIN
    int n,D;int p;int L;int v;
    int suml=0;double tot=0;
    while(cin>>n>>D)
    {
        suml=0;tot=0;
        if(!n&&!D)break;
        for(int i=0;i<n;i++)
        {
        cin>>p>>L>>v;
        tot+=2.0*L/v;
        suml+=L;
        }
        tot+=(D-suml);
        printf("Case %d: %.3f\n\n",id++,tot);
    }
}

 

posted @ 2018-08-24 14:47  erge1998  阅读(90)  评论(0编辑  收藏  举报