POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 17578 | Accepted: 12361 |
Description
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
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
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 <stdio.h>
#include <string.h> int main()
{
int n;
int i, j;
int a[20], b[20]; while(scanf("%d", &n)&&n!=-1)
{
for(i=0; i<n; i++)
{
scanf("%d %d", &a[i], &b[i] );
}
int ans=0, t=0; for(j=0; j<n; j++)
{
ans=ans+a[j]*(b[j]-t);
t=b[j];
}
printf("%d miles\n", ans );
}
return 0;
}
POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)的更多相关文章
- [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 ...
- 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 分类: POJ 2015-06-09 17:47 9人阅读 评论(0) 收藏
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17967 Accepted: 12596 Des ...
- E - Speed Limit(2.1.1)
E - Speed Limit(2.1.1) Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I ...
- 利用链式队列(带头节点)解决银行业务队列简单模拟问题(c++)-- 数据结构
题目: 7-1 银行业务队列简单模拟 (30 分) 设某银行有A.B两个业务窗口,且处理业务的速度不一样,其中A窗口处理速度是B窗口的2倍 —— 即当A窗口每处理完2个顾客时,B窗口处理完1个顾客 ...
- zoj 2176 Speed Limit
Speed Limit Time Limit: 2 Seconds Memory Limit: 65536 KB Bill and Ted are taking a road trip. B ...
- 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 2993 Emag eht htiw Em Pleh【模拟画棋盘】
链接: http://poj.org/problem?id=2993 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...
随机推荐
- java面试题之sleep()和wait()方法的区别
sleep方法: 属于Thread类中的方法:会导致程序暂停执行指定的时间,让出cpu该其他线程,但是他的监控状态依然保持着,当指定时间到了之后,又会自动恢复运行状态:在调用sleep方法的过程中,线 ...
- Honey Heist
5092: Honey Heist 时间限制: 1 Sec 内存限制: 128 MB 题目描述 0x67 is a scout ant searching for food and discover ...
- net8:XML的读写操作【广告控件的XML文件实例】
原文发布时间为:2008-08-05 -- 来源于本人的百度文章 [由搬家工具导入] 【用了datalist控件,datalist控件自己学会,主要知道其他按钮COMMANDNAME属性应该改为edi ...
- MySQL-JDBC Loadbalance深入解析
背景说明 公司的整个电商系统搭建在华为云上,根据老总的估计,上线3个月之后日订单量会达到百万级别,保守估计3个月之后总订单个数预计会有5千万.MySQL单表达到千万级别,就会出现明显的性能问题.根据如 ...
- MYSQL 中GROUP BY
group by 用法解析 group by语法可以根据给定数据列的每个成员对查询结果进行分组统计,最终得到一个分组汇总表. SELECT子句中的列名必须为分组列或列函数.列函数对于GROUP BY子 ...
- python3.6安装遇到的问题
Ubuntu16.04版本最新的Python 3.x版本3.5 . 可以从源代码执行安装最新稳定版本3.6. 要安装Python 3.6 ,请运行以下命令: # wget https://www.py ...
- 转:c++ 11 新特性
声 明:本文源自 Danny Kalev 在 2011 年 6 月 21 日发表的<The Biggest Changes in C++11(and Why You Should Care)&g ...
- android 长按弹出菜单,复制,粘贴,全选
<!-- 定义基础布局LinearLayout --> <LinearLayout xmlns:android="http://schemas.android.com/ap ...
- SolidEdge 工程图中如何快速将同一类元素放到同一个图层
在图层选项卡中新建一个尺寸线图层 点击聪慧选项(把它点凹下去),然后点击任意尺寸线,弹出聪慧选取选项,点击确定,则自动选择了所有尺寸线 点击移动图元,把刚才选中的所有尺寸线都移动到这个图层即可 ...
- EF使用自定义字符串连接数据库
edmx的构造函数: public TestCheckUpdatesEntities(): base(Config.DataBaseConnectionString(), "TestChec ...