Biker's Trip OdometerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6880 Accepted Submission(s): 4564 http://acm.hdu.edu.cn/showproblem.php?pid=1038 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.
Input Input consists of multiple datasets, one per line, of the form:
Output For each data set, print:
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 |
代码:
#include<iostream>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#define inf 0x3f3f3f3f
#define ip 3.1415927
using namespace std;
int main()
{
double d,num,t,sum,v;
int h=1;
while(cin>>d>>num>>t)
{
if(num==0)
break;
sum=ip*d*num;
sum/=63360;
v=sum*3600/t;
cout<<"Trip #"<<h++<<": "<<fixed<<setprecision(2)<<sum<<" "<<v<<endl;
}
return 0;
}