Idea: The key point of this question is based on the description of the topic and test data to get inspired, the ship is
Drawn from the other side. There is a specific scene in mind, it can be very simple.
1#include <cstdio>2 intMain ()3 {4 DoubleD, P, L, V, SUM, flag =0;5 intN, Kase =1;6 while(~SCANF ("%d%lf", &n, &d))7 {8 if(n = =0&& D = =0) Break;//Jump9sum =0;Ten while(n--) One { Ascanf"%lf%lf%lf", &p, &l, &v); -Sum + =2*l/v;//The boat came from the other side, and then across the river, spent a total of time on the water -D-= l;//The rest is the length of the land. the } - if(n = =0) - { -printf"Case %d:", Kase + +);//when n is 0, the direct output D +printf"%.3lf\n", d); - Continue; + } Asum + = D;//the length of the land, the total time . at //if (flag + +) printf ("\ n");//just started with this step, the result PE a pitch. -printf"Case %d:", Kase + +); -printf"%.3lf\n\n", sum);//Note the output format - } - return 0; -}
View Code
HDU3232 Crossing Rivers