Biker‘s Trip Odometer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4871 Accepted Submission(s): 3237
Problem Description
Most 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 will 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 be calculated if you know how many revolutions the wheel has made. In addition, if the time it takes to complete the revolutions is known,
the average speed can also be calculated.
For this problem, you will write a program to determine the total distance traveled (in miles) and the average speed (in Miles 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 is no slipping or skidding.
Input
Input consists of multiple datasets, one per line, of the form:
diameter revolutions time
The diameter is expressed in inches as a floating point value. The revolutions is an integer value. The time is expressed in seconds as a floating point value. Input ends when the value of revolutions is 0 (zero).
Output
For each data set, print:
Trip #N: distance MPH
Of course N should be replaced by the data set number, distance by the total distance in miles (accurate to 2 decimal places) and MPH by the speed in miles per hour (accurate to 2 decimal places). Your program should not generate any output for the ending case
when revolutions is 0.
Constants
For p use the value: 3.1415927.
There are 5280 feet in a mile.
There are 12 inches in a foot.
There are 60 minutes in an hour.
There are 60 seconds in a minute.
There are 201.168 meters in a furlong.
Sample Input
26 1000 5 27.25 873234 3000 26 0 1000
Sample Output
Trip #1: 1.29 928.20 Trip #2: 1179.86 1415.84
Source
Recommend
We have carefully selected several similar problems for you: 1032 1036 1064 1084 1027
话说今天高考啊,祝所有考生能考出自己理想的成绩!然后言归正传,也是有几天没做题了!这道题,比以往还要水一些,只是英语不好的同学可能看起来很吃力!(比如说我......)其实如果你知道题目什么意思,你就会瞧不起这道题了.......
解释一下本题的意思:(输出保留两位小数)
题目包含多组输入数据,要求每组输入数据:
d(轮胎的直径) c(转动的圈数) t(自行车走的时间)
然后让你输出:
Trip #(第几组): 走了多少英里(而自行车走路程相当于步数这里要进行转换格式) 自行车的速度
然后我有必要解释一下输出要求:(本题如果有难点,那就在这里了,英文渣伤不起)
对于每组数据的建立和输出:
Trip #N: distance MPH
当然N应该被具体的数字组来替换,distance是总的英里数(保留2位小数)并且MPH是每小时的速度(保留2位小数)。
最后当转动的圈数是0的时候,你的程序不应该生成任何输出。
常量:
对于Pi用:3.1415926.
5280步相当于1英里.
12英寸相当于1步.
60分钟等于1小时
60秒等于1分钟.
201.168米等于1弗朗.(根本没用这个!吓唬人的!)
拓展知识:
首先应该知道商为定值的两个量成正比例,积为定值的两个量成反比例。
设一定的距离是s,车轮直径是d,车轮半径是r,转动圈数是n。
根据直径和半径关系有d=2r,即r=d/2。
车轮转一圈所走路程为车轮的周长,就是2πr,也就是πd。
车轮要转动n圈才走s距离,所以nπd=s。
距离一定,所以s是定值,所以nd=s/π也是定值。
因此n和d的积是定值,说明它们是反比例关系。
即车轮的直径和它转动的圈数组成比例,成反比例。
上代码(借鉴了网络......博主英语是真的不好!):
#include<iostream> #include<cstdio> #define Pi 3.1415926 using namespace std; int main() { double d,c,t; double sum,v; int j=0; while(scanf("%lf%lf%lf",&d,&c,&t)!=EOF) { if(c==0) break; sum=(Pi*d*c)/(12*5280); v=1.0*(sum*60*60)/t; printf("Trip #%d: %.2lf %.2lf\n",++j,sum, v); } return 0; }
HDU-1038-Biker's Trip Odometer(C++ && 提高英语能力!)