1029: snow cleaning

Source: Internet
Author: User
Description

James's city had a heavy snow last night and all the roads were covered with snow. In order to ensure smooth traffic, snow removal vehicles need to be used to clean up the snow on the road, but the city only has one snow removal vehicle.
There are two lanes for each road in the city. A Snow-removing vehicle can clear the snow on one road in one way, and a snow-removing vehicle can change its direction (including U-shaped turns) at any intersection ), at the same time, you can turn around (U-shaped) at the end of any road to another lane.
The snow-removing vehicle is driving at a speed of 20 km/h during the snow-removing process, and traveling at a speed of 50 km/h on the Lane where the snow has been cleared.
Now, how long does it take for the snow-removing vehicle to clear all lanes on all roads and finally return to the garage?

Input Format

The first line of the input contains two integers x and y, indicating the coordinates of the garage where the snow-removing car is parked.
In the next several rows, input four real numbers X1, Y1, X2, Y2 in each row to indicate the starting point coordinates of a certain road. All roads are straight roads.
The coordinates of the garage must be on the line segment of a certain road.
All coordinate units in the input are meters.

Output

The minimum time required for returning to the garage after cleaning all lanes of all roads is output, in the format of HH: Mm. The result is rounded to minutes.

Sample Input

0 0
0 0 10000 10000
5000-10000 5000 10000
5000 10000 10000 10000

Sample output

3:55

How is the shortest possible?

One track is divided into two lines, and you can jump to the other to clean up at the end of the cleaning. The minimum time is to clear the snow and return to the origin. Remember to clean up the snow of the two lines.

 1 #include<stdio.h> 2 #include<math.h> 3  4 int main() 5 { 6         double x1,y1,x2,y2,s=0,t; 7         int m; 8         scanf("%*d%*d"); 9         while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF)10                 s+=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));11         t=s/20000*2;12         m=(t-(int)t)*60+0.5;13         if(m==60)14                 printf("%02d:00\n",(int)t+1);15         else16                 printf("%02d:%02d\n",(int)t,m);17         return 0;18 }

 

1029: snow cleaning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.