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);
    }
}

猜你喜欢

转载自blog.csdn.net/linruier2017/article/details/82018077
今日推荐