poj 2017 Speed Limit
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 17704 | Accepted: 12435 |
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
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 <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的更多相关文章
- [ACM] poj 2017 Speed Limit
Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 17030 Accepted: 11950 Des ...
- POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)
Sp ...
- 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 ...
- 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 ...
- Speed Limit
http://poj.org/problem?id=2017 #include<stdio.h> int main() { int n,mile,hour; ) { ,h = ; whil ...
- POJ 2017
#include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("t ...
随机推荐
- 等等,你可能误解nodejs了–通俗的概括nodejs的真相
最近刚把产品从cpp平台迁移到nodejs平台了. 很多以前关于nodejs的观念被颠覆了. 这里分享出来, 欢迎大家批评指正. "nodejs是做服务器端开发的, 它一定和web相关,几 ...
- DEV 之 有些控件不允许拖动。
DEV 之 有些控件不允许拖动. 设置一个参数即可解决问题
- OO 面向对象的概念
面向对象的概念 一.什么是面向对象? 传统的:世间万物都是对象.例如:桌子,凳子,电脑等: 个人理解: 1.软件开发方法: 2.面向对象是一种解决问题和分析问题的(编程)一种思想: 3.他是通过面向过 ...
- [Perl]Windows 系统 Unicode 文件名操作(新建、重命名、枚举、复制)全攻略
[Perl] Windows 系统 Unicode 文件名操作(新建.重命名.枚举.复制)全攻略 环境 XP/WIN7 Perl v5.16 编辑整理:PerlMonk.523066680 常见的那些 ...
- 比较旧的写法:验证车牌、手机号、电话、qq等
1.验证车牌代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- “全栈2019”Java第二十五章:流程控制语句中循环语句while
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...
- 洛谷P5273 【模板】多项式幂函数 (加强版)
题面 传送门 题解 这里最麻烦的问题就是它不保证\(A_0=1\) 如果\(A_0>1\),那么直接整个多项式乘上个\(A_0\)的逆元,最后输出答案的时候再把答案乘上\({A_0}^m\) 如 ...
- centos yum安装php5.6.19 remi源按照
yum安装php5.6 多版本php共存 remi安装方法 http://www.servermom.org/how-to-enable-remi-repo-on-centos-7-6-and-5/2 ...
- thinkphp3.2----设置静态缓存
开启静态缓存后,页面刷新时获取的是静态页面,控制器增加输出内容时页面还是一样,除非超过缓存时间或html结构发生变化才重新生成页面缓存 1.定义静态缓存目录 define("HTML_PAT ...
- 2016级算法第三次上机-D.双十一的抉择
915 双十一的抉择 思路 中等题.简化题目:一共n个数,分成两组,使得两组的差最接近0,就是说要使两组数都尽可能的接近sum/2. 思路还是很混乱的,不知道如何下手,暴力也挺难的,还不能保证对.想一 ...