Speed Limit
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 17704   Accepted: 12435

Description

Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can record their speed and the total time they have driven. Unfortunately, their record keeping strategy is a little odd, so they need help computing the total distance driven. You are to write a program to do this computation.

For example, if their log shows

Speed in miles perhour Total elapsed time in hours
20 2
30 6
10 7

this means they drove 2 hours at 20 miles per hour, then 6-2=4 hours at 30 miles per hour, then 7-6=1 hour at 10 miles per hour. The distance driven is then (2)(20) + (4)(30) + (1)(10) = 40 + 120 + 10 = 170 miles. Note that the total elapsed time is always since the beginning of the trip, not since the previous entry in their log.

Input

The input consists of one or more data sets. Each set starts with a line containing an integer n, 1 <= n <= 10, followed by n pairs of values, one pair per line. The first value in a pair, s, is the speed in miles per hour and the second value, t, is the total elapsed time. Both s and t are integers, 1 <= s <= 90 and 1 <= t <= 12. The values for t are always in strictly increasing order. A value of -1 for n signals the end of the input. 

Output

For each input set, print the distance driven, followed by a space, followed by the word "miles"

Sample Input

3
20 2
30 6
10 7
2
60 1
30 5
4
15 1
25 2
30 3
10 5
-1

Sample Output

170 miles
180 miles
90 miles

Source

分析:

 #include <cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
int main(){
int n;
while(cin>>n&&n!=-){
int s,t=,dis=;
while(n--){
int tt;
cin>>s>>tt;
dis+=s*(tt-t);
t=tt;
}
printf("%d miles\n",dis);
}
return ;
}

poj 2017 Speed Limit的更多相关文章

  1. [ACM] poj 2017 Speed Limit

    Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17030   Accepted: 11950 Des ...

  2. POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)

                                                                                                      Sp ...

  3. Poj 2017 Speed Limit(水题)

    一.Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they ...

  4. Speed Limit 分类: POJ 2015-06-09 17:47 9人阅读 评论(0) 收藏

    Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17967   Accepted: 12596 Des ...

  5. E - Speed Limit(2.1.1)

    E - Speed Limit(2.1.1) Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I ...

  6. zoj 2176 Speed Limit

    Speed Limit Time Limit: 2 Seconds      Memory Limit: 65536 KB Bill and Ted are taking a road trip. B ...

  7. Kattis - Speed Limit

    Speed Limit Bill and Ted are taking a road trip. But the odometer in their car is broken, so they do ...

  8. Speed Limit

    http://poj.org/problem?id=2017 #include<stdio.h> int main() { int n,mile,hour; ) { ,h = ; whil ...

  9. POJ 2017

    #include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("t ...

随机推荐

  1. Arcgis Android 坐标转换

    http://spatialreference.org/首先,在上面的网站查出现有的坐标srid,然后查出目标Srid. 参考api 示例代码 Point point = new Point(120. ...

  2. 一些参考网站 - Reference Documentation - Website Address

    Reference Documentation - Website Address MSDN Visual Studio 2015官方文档 https://msdn.microsoft.com/zh- ...

  3. 获取hyper-v和vmware虚机状态

    在vmware的PowerCLI和微软的scvmm的PowerShell中可以通过Get-VM命令来获取虚拟机的信息.下面我们用代码的方式去实现,代码相关类方法就是对命令的封装. vmware api ...

  4. C#加密解密总览

    C#SHA加密 C#MD5加密 C#RSA加密解密 C#DES加密和解密 C#AES加密和解密

  5. 在.net Core中使用StackExchange.Redis 2.0

    StackExchange.Redis 2.0做了大量的改进包括使用了高性能的IO库System.IO.Pipelines来提升性能以及解决Timeouts问题, 但是在.net Core2.2之前为 ...

  6. 数据库_mysql多表操作

    多表操作        实际开发中,一个项目通常需要很多张表才能完成.例如:一个商城项目就需要分类表(category).商品表(products).订单表(orders)等多张表.且这些表的数据之间 ...

  7. 解决$ git clone fatal: Authentication failed

    今天在使用git clone克隆项目的时候报如下错误: $ git clone XXXXXX Cloning into 'XXXX'... fatal: Authentication failed f ...

  8. [ActionScript 3.0] 自制简单拾色器

    colorBoard为库中绑定的影片剪辑,colorBoard中包含影片剪辑currColor,文本colorText,影片剪辑close: colorDot为库中绑定的影片剪辑,colorDot中包 ...

  9. Python爬取网上车市[http://www.cheshi.com/]的数据

    #coding:utf8 #爬取网上车市[http://www.cheshi.com/]的数据 import requests, json, time, re, os, sys, time,urlli ...

  10. 数学 CF1068B LCM

    CF1068B LCM 给定一个正整数\(b (1\leq b \leq 10^{10})\). 把一个正整数a从1枚举到\(10^{18}\),求有多少种不同的\(\large \frac{[a,b ...