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. HTTP 常见异常状态及Delphi IDHTTP 控件处理方式

    以下部分为网上查找,部分为工作中整理 200:请求成功 202:请求被接受,但处理尚未完成 302:请求到的资源在一个不同的URL处临时保存     处理方式:重定向到临时的URL(IDHTTP处理方 ...

  2. linux权限及目录

    [-][rwx][r-x][r--] r:4 - 读  w:2 - 写  x:1 - 执行 1:代表文件类型 2:代表文件所有者的权限 3:代表文件所在组的权限 4:代表其他用户的权限 chgrp:修 ...

  3. SOLR企业搜索平台 一 (搭建SOLR)

    前提是已经安装了java的环境,环境变量的配置不做为讲解,网上也有大量资料.下面以linux为例来说明如何搭建好一个solr 1)首先下载solr,下载地址:http://mirror.bit.edu ...

  4. 使用SqlBulkCopy进行批量插入数据时踩过的坑

    之前一直都没用过SqlBulkCopy关键字进行数据插入,更没了解过. 事因:因业务需要在数据表中添加两列,然后将数据插入进表中 之前都是这样写的 dt.Columns.Add(new DataCol ...

  5. c++分块算法(暴力数据结构)

    快要noip了,该写些题解攒攒rp了(逃) 看到题解里那么多线段树啊,树状数组啊,本蒟蒻表示:这都是什么鬼东西? 在所有高级数据结构中,树状数组是码量最小的,跑的也基本是最快的,但理解很难,并且支持的 ...

  6. poj 3468 A Simple Problem with Integers 线段树区间加,区间查询和(模板)

    A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?i ...

  7. Eclipse搭建Android开发环境(安装ADT,Android4.4.2)

    1.检查是否安装JDK, 如果没安装请下载安装 JDK官网http://www.Oracle.com/technetwork/Java/javase/downloads/index.html 2.下载 ...

  8. POJ 1330 Nearest Common Ancestors(lca)

    POJ 1330 Nearest Common Ancestors A rooted tree is a well-known data structure in computer science a ...

  9. php数据库编程---mysql扩展库

    1, Java有一种方式操作数据库, PHP有三种方式来操作mysql数据库.(1)mysql扩展库:(2)mysqli扩展库:(3)pdo: 2, mysql扩展库和mysql数据库区别 3, my ...

  10. ArchLinux 下 VirtualBox 增强设置

    0.前言: 其实这个标题本来不是我的本意,因为我的ArchLinux开机启动报错了!. 原本是一个服务报错,解决就行了对不对.后来我各种搜索大法发现了一个常识错误. 1.报错: 2.过程(赶时间的朋友 ...