E - Speed Limit(2.1.1)
Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u
Description
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
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
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
#include<iostream>
using namespace std;
int main( )
{
int n;
int a,b,s,k;
while(cin>>n&&n>0)
{
s=0,k=0;
while(n--)
{
cin>>a>>b;
s=s+a*(b-k);
k=b; }
cout<<s<<" miles"<<endl;
}
return 0;
}
E - Speed Limit(2.1.1)的更多相关文章
- Speed Limit 分类: POJ 2015-06-09 17:47 9人阅读 评论(0) 收藏
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17967 Accepted: 12596 Des ...
- [ACM] poj 2017 Speed Limit
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17030 Accepted: 11950 Des ...
- poj 2017 Speed Limit
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17704 Accepted: 12435 Des ...
- zoj 2176 Speed Limit
Speed Limit Time Limit: 2 Seconds Memory Limit: 65536 KB Bill and Ted are taking a road trip. B ...
- POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)
Sp ...
- Kattis - Speed Limit
Speed Limit Bill and Ted are taking a road trip. But the odometer in their car is broken, so they do ...
- Poj 2017 Speed Limit(水题)
一.Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they ...
- Speed Limit
http://poj.org/problem?id=2017 #include<stdio.h> int main() { int n,mile,hour; ) { ,h = ; whil ...
- PyTorch DataLoader NumberWorkers Deep Learning Speed Limit Increase
这意味着训练过程将按顺序在主流程中工作. 即:run.num_workers. ,此外, ,因此,主进程不需要从磁盘读取数据:相反,这些数据已经在内存中准备好了. 这个例子中,我们看到了20%的加 ...
随机推荐
- oracle在schema是什么意思?
看来有些人还在schema不明白的真正含义,今天,我再次整理.我希望能帮助. 我们先来看看它们的定义:A schema is a collection of database objects (use ...
- 发布Ubuntu/Linux系统cache,增加可用内存空间
桌面Ubuntu总内存4G,但free只有内存有100M 重视top命令检查看到真正的能力free内存.以下是真正的内存使用情况的看法有一个命令. watch -n 1 cat /proc/memin ...
- Java Web整合开发(79) -- Struts 2
一. Struts 2.x 概述 不继承任何类的Action Struts 2的Action并不一定要实现Action接口或者继承ActionSupport,任何POJO都可以做Action,只要这个 ...
- 191. Number of 1 Bits Leetcode Python
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also know ...
- 单选框和下拉框的jquery操作
单选框 <input type="radio" name="rdSendType" value="email" checked=&qu ...
- 【工具】JAVA 在单元读取文件并比较
package test20140709; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; ...
- mapreduce任务失败、重试、猜測式运行机制小结
mapreduce中我们自己定义的mapper和reducer程序在运行后有可能遇上出错退出的情况,mapreduce中jobtracker会全程追踪任务的运行情况,对于出错的任务mapreduce也 ...
- Linux课程_系统配置和日常维护
1.设置命令输入提示格公式:"username:当前文件夹$" 2.设置命令输入提示行格式为:"当前系统时间-用户#"(提示:Shell将通过反引號" ...
- IIS7和IIS7.5备份和还原的方法
windows2008的iis配置备份和iis6不同,在iis7中没有了6原来的保存配置xml的选项,而采用的是dos命令来进行iis7的备份.以下是win2008上iis7备份的方法. 首先打开CM ...
- 【DP专辑】ACM动态规划总结
转载请注明出处,谢谢. http://blog.csdn.net/cc_again?viewmode=list ---------- Accagain 2014年5月15日 ...