Hangzhou Electric oj--Bicycle Speed meter

Source: Internet
Author: User

Biker ' s trip odometer

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 2810 Accepted Submission (s): 1922


Problem Descriptionmost bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A Magnet is attached to one of the spokes on the front wheel so that it'll line up with the Hall Effect switch once per Revolution of the wheel. The speedometer monitors the sensor to count wheel revolutions. If the diameter of the wheel is known, the distance traveled can be easily being calculated if you know how many revolutions The wheel has made. In addition, if the time it takes to complete the revolutions are known, the average speed can also be calculated.
For this problem, you'll write a program to determine the total distance traveled (in miles) and the average speed (in M Iles Per Hour) Given the wheel diameter, the number of revolutions and the total time of the trip. You can assume that the front wheel never leaves the ground, and there are no slipping or skidding.


Inputinput consists of multiple datasets, one per line, of the form:

Diameter Revolutions Time

The diameter is expressed with inches as a floating point value. The revolutions is an integer value. The time is expressed with seconds as a floating point value. Input ends when the value of revolutions is 0 (zero).


Outputfor each data set, print:

Trip #N: Distance MPH

Of course N should is replaced by the data set number, distance by the total distance in miles (accurate to 2 decimal plac ES) and MPH by the speed of miles per hour (accurate to 2 decimal places). Your program should no generate any output for the ending case when revolutions is 0.

Constants

For P use the value:3.1415927.
There is 5280 feet in a mile.
There is inches in a foot.
There is minutes in an hour.
There is seconds in a minute.
There is 201.168 meters in a furlong.


Sample Input26 1000 527.25 873234 300026 0 1000


Sample outputtrip #1:1.29 928.20Trip #2:1179.86 1415.84


Sourcegreater New York 2003
1#include <stdio.h>2 #defineP 3.14159273 #defineTofeet (x) x/12.04 #defineTomiles (x) x/5280.05   6 intMain () {7     DoubleDiameter//diameter8     intRevolutions;//number of turns9     DoubleTime//TimeTen     DoubleS//Distance One     intCount=1;  A      while(SCANF ("%LF%D%LF",&diameter,&revolutions,&Time ), revolutions) { -Time/=3600;  -Diameter/=63360;  thes=diameter*p*revolutions;  -printf"Trip #%d:%.2lf%.2lf\n", count++,s,s/Time );  -     }   -}

Hangzhou Electric oj--Bicycle Speed meter

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.