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 ...
随机推荐
- 【bzoj4320】【ShangHai2006 Homework】【并查集+离线处理】
ShangHai2006 Homework Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 918 Solved: 460[Submit][Statu ...
- AXMLPrinter2.jar反编译xml文件
apk里的AndroidManifest.xml 为二进制文件,可通过AXMLPrinter2.jar包反编译出来 cmd命令行运行一下命令: java -jar AXMLPrinter2.jar A ...
- 染色(bzoj 2243)
Description 给定一棵有n个节点的无根树和m个操作,操作有2类: 1.将节点a到节点b路径上所有点都染成颜色c: 2.询问节点a到节点b路径上的颜色段数量(连续相同颜色被认为是同一段),如“ ...
- 乘法运算(codevs 3254)
题目描述 Description 编制一个乘法运算的程序. 从键盘读入2个100以内的正整数,进行乘法运算并以竖式输出. 输入描述 Input Description 输入只有一行,是两个用空格隔开的 ...
- Laravel 5 Form 和 HTML 的使用
最近在用 laravel 5 做例子,在做到表单的时候,习惯性的使用 Form::open() 结果发现提示错误,没有这个类, 好吧,找了找,发现 在laravel 5 中,把 from 和 html ...
- msp430入门学习44
msp430的其他十二 msp430入门学习
- Mybatis resultMap空值映射问题
参考博客:https://www.oschina.net/question/1032714_224673 http://stackoverflow.com/questions/22852383/how ...
- hdu4862 2014多校B题/ 费用流(最优情况下用不大于K条路径覆盖)(不同的解法)
题意: 一个数字矩阵,可以出发K次,每次可以从右边或者下面走,要求(在收益最大情况下)覆盖全图,不能则输出-1.(规则:每次跳一步的时候若格子数字相等则获得该数字的能量,每跳一步消耗距离的能量).每个 ...
- 关于 最短路条数 和 边不可重复最短路条数问题 /hdu3599(边不可重复最短路)
原先一直在做一道省赛题,由于题意错误理解成球最短路条数,误打误撞敲了最短路条数,又发现hdu3599(多校)求边不可重复最短路条数.下面说说俩种问题解法: 最短路条数: 求一个图一共一几条最短路径,思 ...
- (5)Swing事件
import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; publi ...