HDU-1038-Biker's Trip Odometer(C++ && 提高英语能力!)

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

Greater New York 2003

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++ && 提高英语能力!)

时间: 2024-10-07 06:55:39

HDU-1038-Biker's Trip Odometer(C++ && 提高英语能力!)的相关文章

HDU 1038[Biker&#39;s Trip Odometer]简单计算

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1038 题目大意:给轮子直径,转数,时间.要求输出走过的距离和时速(mile为单位) 关键思想:纯算 代码如下: #include <iostream> using namespace std; #define pi 3.1415927 int main(){ double d,r,t,l; int cnt=1; while(cin>>d>>r>>t&&a

杭电 HDU 1038 Biker&#39;s Trip Odometer

Biker's Trip Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4745    Accepted Submission(s): 3144 Problem Description Most bicycle speedometers work by using a Hall Effect sensor faste

HDU 1038 - Biker&#39;s Trip Odometer

算一下路程和速度... 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 const double p=3.1415927; 5 double dia,tim,dis,sped; 6 int rev; 7 int main() 8 { 9 int k=1; 10 while(cin>>dia>>rev>>tim,rev) 11 { 12 dia/=12*5280;

SOJ 1051 Biker&#39;s Trip Odometer

题目大意:多组测试样例,每组测试样例输入3个数,第一个表示车轮的直径(浮点型,单位英寸),第二个表示车轮的转数(整型),第三个表示花费的时间(浮点型,单位秒). 求解车轮的总路程(单位:英里)和平均速度(单位:英里/每小时). 以"Trip #: distance MPH"的格式输出. 当转数输入为零时,结束程序. 解题思路:本题主要考察单位的转化,具体的转化系数在题目中有给出.求车轮周长的π是3.1415927. 先将直径的英寸单位转化为英里单位,将时间的秒单位转化为小时. 代码如下

HDOJ1038 Biker&#39;s Trip Odometer

Biker's Trip Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4038    Accepted Submission(s): 2703 Problem Description Most bicycle speedometers work by using a Hall Effect sensor faste

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker&#39;s Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

1.2.1 Biker's Trip Odometer #include<stdio.h> #include<math.h> const double PI=acos(-1.0); /* 计算题,根据公式做就行,PI*d*r/(12*5280);res1/t*3600; 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

sicily 1051. Biker&#39;s Trip Odomete

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 will line up with the Hall Effect switch once per revolution of

程序员提高编程能力万无一失的办法

那就是去读别人写的代码.读那些你常用的库.编程框架的源代码,读那些你景仰的大牛的源代码,读代码里的测试(测试本身就是一种有效的文档):读代码.改代码.运行代码. 其实,所谓写程序,大部分的时间都是花在读代码上,“写”的部分耗时极少:所以把“读”的技能训练好了,是很有好处的. 提高编程能力万无一失的办法 编注:这篇文章最初于 2010 年 5 月为 Fuel Your Coding 网站而写.不幸的是,那个网站已经不复存在了,所以我将这篇文章重新发布.为了紧跟时代步伐,我想过对其进行更新,但我又觉

【心灵鸡汤】浪子助你提高解决问题能力

今天我们聊聊开心的话题 :) 我们都知道无论在什么行业,学习能力才是发展的最重要的,用潜力来说也可以. 但是学习能力是什么,其实很虚,企业如何为你的学习能力买单发工资.我觉得可以用解决问题的能力来衡量 我们从几张截图开始我们的话题 截图一: 截图二: 截图三: 善用互联网的搜索工具 作为新手难免是遇到问题就到各个技术群里去询问,这个很正常,我也是这么经历过来的.但是一般都有工作,谁又能及时给予帮助,基本不可能了.所以还要要靠自己,我们就那第一张截图来说,根据提示:no input file sp