杭电ACM HDU 3424 Range
来源:互联网 发布:io1.1鼠标弹道优化 编辑:程序博客网 时间:2024/06/05 11:07
Range
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 245 Accepted Submission(s): 153
Problem Description
Some automobiles display the estimated driving range, that is, the distance you can expect to drive it (without adding fuel) before running out of fuel. Here is how it works: periodically, the vehicle's computer records the odometer reading and the weight of fuel in the fuel tank. From this data, the fuel consumption over a certain distance can be computed.
From the fuel consumption and the most recent measurement of fuel tank contents (which we assume is current for all practical purposes), the range can be calculated. Intervals over which the quantity of fuel increased (fuel was added to the tank) will not be used in the computations. For example, in the first problem instance of the sample input, the interval where the fuel weight increased from 29.9 kilograms to 34.2 kilograms will not be used. In this example, 16.3 kilograms of fuel were consumed over a distance of 228.6
kilometers. Therefore, the most recently measured fuel contents of 31.2 kilograms will enable you to drive another 438 kilometers (rounded to the nearest integer). The input will always contain at least one interval (two consecutive lines of input) where no fuel was added to the tank.
From the fuel consumption and the most recent measurement of fuel tank contents (which we assume is current for all practical purposes), the range can be calculated. Intervals over which the quantity of fuel increased (fuel was added to the tank) will not be used in the computations. For example, in the first problem instance of the sample input, the interval where the fuel weight increased from 29.9 kilograms to 34.2 kilograms will not be used. In this example, 16.3 kilograms of fuel were consumed over a distance of 228.6
kilometers. Therefore, the most recently measured fuel contents of 31.2 kilograms will enable you to drive another 438 kilometers (rounded to the nearest integer). The input will always contain at least one interval (two consecutive lines of input) where no fuel was added to the tank.
Input
The input contains data for a number of problem instances. Each problem instance consists of three or more (odometer reading, fuel weight) pairs, one pair per line. Distances are measured in kilometers and fuel weight in kilograms. All input numbers will be given to one decimal place. The end of each problem instance will be signaled by a (0.0, 0.0) pair. The last problem instance will be followed by a (-1.0, -1.0) pair.
Output
For each problem instance, print the range, rounded to the nearest integer.
Sample Input
18400.5 43.218440.4 40.418482.7 37.018540.2 33.118585.3 29.918620.8 34.218664.6 31.20.0 0.018400.5 43.218440.4 40.418482.7 37.018540.2 33.118585.3 29.90.0 0.0-1.0 -1.0
Sample Output
438415
Source
Rocky Mountain Regional Contest 2009
Recommend
zhouzeyong
#include <cstdio>#include <cmath>using namespace std;#define F(x) abs(x)>1e-6int main(){ double x,y,a,b,s,f; while(scanf("%lf%lf",&x,&y)&&(F(x+1.0)||F(y+1.0))){ s=f=0; while(scanf("%lf%lf",&a,&b)&&(F(a)||F(b))){ if(b<y){ s+=a-x;f+=y-b; } x=a;y=b; } printf("%.0lf\n",s/f*y); }}
- 杭电ACM HDU 3424 Range
- hdu 杭电acm 1002
- 杭电ACM HDU 1004
- 杭电ACM HDU 1002
- 杭电ACM HDU 1008
- 杭电ACM HDU 1013
- 杭电ACM HDU 1014
- 杭电 acm Saving HDU
- 杭电 HDU ACM 圆桌会议
- 杭电 HDU ACM Milk
- 杭电ACM--HDU-1061
- 杭电ACM--HDU-1425
- 杭电ACM-HDU 1982
- 杭电 HDU ACM 1002
- 杭电 hdu ACM 1049 Climbing Worm
- HDU杭电acm题目分类大全
- hdu 杭电acm 2018母牛问题
- 【ACM】杭电 hdu 1482 Counterfeit Dollar
- Spring 学习笔记(一)
- 如何查看android数据库是否建立好 数据是否保存
- 彩色(RGB/HSV)&灰度 图像像素值读取并保存到txt文件
- 操作系统_再识(Linux介绍)
- 批量insert语句的执行技巧
- 杭电ACM HDU 3424 Range
- 分段有序数组合并成有序(空间复杂度为O(1))
- Direct3D的一些小贴士
- 让你成熟至少5岁的8句话
- 图片以流的形式显示到页面
- VC取得环境变量内容
- 分文件夹进行存储上传资源
- Opencv中的HSV取值范围
- android休眠唤醒死机