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. GitHub上创建组织

    4.3. 组织和团队 GitHub 在早期没有专门为组织提供账号,很多企业用户或大型开源组织只好使用普通用户账号作为组织的共享账号来使用.后来,GitHub推出了组织这一新的账号管理模式,满足大型开发 ...

  2. chrome console cheat sheet

    快捷键 打开console界面快捷键:ctrl+shift+J 清空log:ctrl+L 选项 Log XMLHTTPRequests:显示ajax Preserve log upon navigat ...

  3. ResorceGovernor--基础和Demo

    资源调控器分为三部分:1:资源池,将资源CPU/MEMORY划分到不同的载体上2:负载组,承载负载并将负载映射到不同的资源池3: 分类函数,将不同回话映射到不同的负载组08提供两种预定义的系统资源池1 ...

  4. android hook getdeceiveid

    很多手机软件使用了手机绑定.QQ,微信等.如果使用了不同的设备,则需要验证码. 要用一台手机来模拟与另一台手机一样环境,估计hook 系统的相关函数可以实现. 想着应该有现成的软件的,例如 smart ...

  5. GridView中合并单元格

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Da ...

  6. 学习做爬虫-vs2017

    最近新装了vs2017,安装过程发生了很大的变化,操作变的更加容易了. 下载vs安装程序进行安装.更新界面如图所示,我选择了安装免费个人版(这个是已安装的更新界面,和安装界面差不多) 如图所示,这样的 ...

  7. CancellationTokenSource 取消任务

    using System; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp1 { class Pr ...

  8. WPF成长之路------帧动画(1)

    最近公司的一个项目因为是WPF的,而自己已经很长一段时间没有接触过WPF了,再加上之前没有做过wpf的动画效果,因此在学习的过程中也顺便记录一下,说不定以后还会用上,同时也算是总结一下吧!刚开始写博客 ...

  9. 【Selenium专题】高亮显示页面元素

    高亮显示页面元素主要用到Selenium中使用js的知识点,最常用的是检查元素定位是否正确.此外,实现js的调用大大增强了Selenium的功能.以下是调试通过的案例: import org.open ...

  10. 外网域名映射内网Ip 内网使用外网域名的https证书

    用nslookup www.baidu.com nslookup www.qq.com 15.64.64.53 测试了内网的dns可以解析外网域名 那么我买个外网域名,再对这个外网域名买个证书,然后外 ...