SOJ 1051 Biker's Trip Odometer

题目大意:多组测试样例,每组测试样例输入3个数,第一个表示车轮的直径(浮点型,单位英寸),第二个表示车轮的转数(整型),第三个表示花费的时间(浮点型,单位秒)。

     求解车轮的总路程(单位:英里)和平均速度(单位:英里/每小时)。

     以"Trip #: distance MPH"的格式输出。

     当转数输入为零时,结束程序。

解题思路:本题主要考察单位的转化,具体的转化系数在题目中有给出。求车轮周长的π是3.1415927.

     先将直径的英寸单位转化为英里单位,将时间的秒单位转化为小时。

代码如下:

 1 #include <iostream>
 2 #include <iomanip>
 3 using namespace std;
 4
 5 int main() {
 6     double d, t;
 7     int foot2inch = 12;
 8     int mile2feet = 5280;
 9     int second2hour = 60 * 60;
10     double p = 3.1415927;
11     int r;
12     int i = 0;
13
14     while (cin >> d >> r >> t, r) {
15         i++;
16         double dm = d / foot2inch / mile2feet;
17         double th = t / second2hour;
18         double distance = p * dm * r;
19         double hpm = distance / th;
20
21         cout << "Trip #" << i << ": " << fixed << setprecision(2) << distance << " " << fixed << setprecision(2) << hpm << endl;
22     }
23
24     return 0;
25 }

SOJ 1051 Biker's Trip Odometer

时间: 2024-10-12 18:52:31

SOJ 1051 Biker's Trip Odometer的相关文章

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

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

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

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;

杭电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

HDU-1038-Biker&#39;s Trip Odometer(C++ &amp;&amp; 提高英语能力!)

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 faste

sicily 1051 小数的有效数字

1051. Biker's Trip Odomete Constraints Time Limit: 1 secs, Memory Limit: 32 MB 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

编程题目分类(剪辑)

1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. 模拟 12. 算术与代数 13. 组合问题 14. 数论 15. 网格,几何,计算几何 [编程入门] PC 110101, uva 100, The 3n+1 problem, 难度 1 PC 110102, uva 10189, Minesweeper, 难度 1 PC 110103, uva 10137, The T