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

 #include <stdio.h>
#define P 3.1415927
#define toFeet(x) x/12.0
#define toMiles(x) x/5280.0 int main(){
double diameter;//直径
int revolutions;//转数
double time;//时间
double s; //距离
int count=;
while(scanf("%lf%d%lf",&diameter,&revolutions,&time),revolutions){
time/=;
diameter/=;
s=diameter*P*revolutions;
printf("Trip #%d: %.2lf %.2lf\n",count++,s,s/time);
}
}

杭电OJ--自行车计速器的更多相关文章

  1. C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~

    暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...

  2. 杭电oj 2095 & 异或^符号在C/C++中的使用

    异或^符号,在平时的学习时可能遇到的不多,不过有时使用得当可以发挥意想不到的结果. 值得注意的是,异或运算是建立在二进制基础上的,所有运算过程都是按位异或(即相同为0,不同为1,也称模二加),得到最终 ...

  3. 用python爬取杭电oj的数据

    暑假集训主要是在杭电oj上面刷题,白天与算法作斗争,晚上望干点自己喜欢的事情! 首先,确定要爬取哪些数据: 如上图所示,题目ID,名称,accepted,submissions,都很有用. 查看源代码 ...

  4. 杭电oj 4004---The Frog Games java解法

    import java.util.Arrays; import java.util.Scanner; //杭电oj 4004 //解题思路:利用二分法查找,即先选取跳跃距离的区间,从最大到最小, // ...

  5. 『ACM C++』HDU杭电OJ | 1415 - Jugs (灌水定理引申)

    今天总算开学了,当了班长就是麻烦,明明自己没买书却要带着一波人去领书,那能怎么办呢,只能说我善人心肠哈哈哈,不过我脑子里突然浮起一个念头,大二还要不要继续当这个班委呢,既然已经体验过就可以适当放下了吧 ...

  6. 杭电oj————2057(java)

    question:A+ B again 思路:额,没啥思路/捂脸,用java的long包里的方法,很简单,只是有几次WA,有几点要注意一下 注意:如果数字有加号要删除掉,这里用到了正则表达式“\\+” ...

  7. 爬取杭电oj所有题目

    杭电oj并没有反爬 所以直接爬就好了 直接贴源码(参数可改,循环次数可改,存储路径可改) import requests from bs4 import BeautifulSoup import ti ...

  8. 杭电OJ——1198 Farm Irrigation (并查集)

    畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...

  9. 杭电OJ——1007 Quoit Design(最近点对问题)

    Quoit Design Problem Description Have you ever played quoit in a playground? Quoit is a game in whic ...

  10. 杭电 OJ 提交代码需要注意的问题

    杭电acm 提交代码需要注意的问题 1. 用 Java 的时候类名请用 Main 2. Java 提交出现 PE 的可能原因有 1) 最基本的错误是空格问题,比如注意每行的末尾是否输出空格 2) 用 ...

随机推荐

  1. 北京南天软件java工程师面试题

    此试题为北京南天软件java工程师面试题(部分) 一.单项选择 (1)下列关于构造方法的叙述中,错误的是(C) A.java语言规定构造方法名与类名必须相同 B.java语言规定构造方法没有返回值,但 ...

  2. Django入门实践(一)

    Django入门实践(一) Django编程思路+入门 认识Django有一个多月了,我觉得学习Django应该先理清它的编程思路.它是典型的MVC框架(在Django里也称MTV),我觉得Djang ...

  3. asp.net做的网站账号登陆后注销不管用了

    最近做了个项目用到了数据库登录,A登陆后把登录状态保,个人信息存在Session里,但是奇怪的是,只要有一个用户登录后在其他电脑上打开上述页面,则也显示A登录状态,注销也不管用了.以前还号的.求大神啊 ...

  4. jquery.range.js左右滑动选取数值插件,动态改变进度。

    作为一个初级前端工作人员,我最近在做一个关于直播的项目,其中一个功能要求是设置延迟时间, 所以就用到了jquery.range.js这个插件.插件中设置$(".single-slider&q ...

  5. 微软必应借PK谷歌突围中国搜索市场

    Bing“必应”是微软2009年推出的搜索品牌(http://www.bing.com),它取代的是同门师兄Live Search.进入2013年,在国内及好莱坞的多部大片里面,我都看到了Bing搜索 ...

  6. android 常用资料

    网上收集保存的一些常用的android资料,写得都比较不错,和大家分享下,共同学习: _ android ListView美化.docx androidshape.docx android_textv ...

  7. Html中DIV成为超级链接,解决在360浏览器+IE9显示小手图标的兼容性!

    Html中DIV成为超级链接,解决在360浏览器+IE9显示小手图标的兼容性! <div style="cursor:pointer;" onclick="sele ...

  8. is和as关键字

    c# 中 is和as 操作符是用来进行强制类型转换的 is : 检查一个对象是否兼容于其他指定的类型,并返回一个Bool值,永远不会抛出异常 object o = new object(); if ( ...

  9. [jQuery]on和bind事件绑定的区别

    on和bind事件绑定的区别 一个demo展示 <!DOCTYPE html> <html lang="zh"> <head> <titl ...

  10. selenium自动化过程中遇到的小问题(未完待续)

    1.chrome浏览器调用不起来 代码没出错的情况下,检查下chrome浏览器的版本与chromedriver.exe的版本是否匹配;下面的表格是根据网上及官网整理的chromedriver与chro ...