POJ 1922 Ride to School 题解
来源:互联网 发布:未来单片机的发展趋势 编辑:程序博客网 时间:2024/06/08 09:51
题意
有若干人从起点以不同时间出发以不同但恒定的速度骑自行车前往距离起点4.5km的终点,有另一个人从起点开始采取跟随最快的人的车跟骑,在路上如果遇到更快的车超过他现在跟的车他会选择更换跟随对象,换成这个更快的车,问经过多少秒,他可以到达终点
思路
如果出发时间为负,显然不会是跟骑的人最后跟的车,如果这辆车更快,跟骑的人根本不可能遇到它,如果它更慢,即使跟骑的人遇到也不会换车。而跟骑的人又会不断跟随遇到的更快的车,那他最后一定是跟随出发时间非负且最快到达终点的车到达。所以我们只需考虑出发时间非负的车到达终点的时间,取最小值即可。
代码
#include <cstdio>#include <cmath>int main(){ int N,V,T,ans; while(1) { scanf("%d",&N); ans=0x7fffffff; if(N==0) break; for(int i=0;i<N;i++) { scanf("%d%d",&V,&T); if(T>=0&&ceil(4.5*3600/V)+T<ans) ans=ceil(4.5*3600/V)+T; } printf("%d\n",ans); } return 0;}
0 0
- POJ 1922 Ride to School 题解
- POJ 1922 Ride to School
- POJ 1922 Ride to School
- POJ 1922 Ride to School
- poj 1922 Ride to School
- poj 1922 Ride to School
- POJ 1922 Ride to School
- POJ:1922 Ride to School
- POJ 1922 - Ride to School
- POJ 1922 Ride to School
- POJ 1922 Ride to School
- POJ-1922 Ride to School
- POJ 1922 Ride to School 解题报告
- Ride to School(POJ 1922)
- Ride to School - POJ 1922 水题
- POJ 1922:Ride to School:水题练java
- POJ 1922 Ride to School 简单模拟
- POJ——1922 Ride to School
- 籍贯
- pycharm下的多个python版本共存(一)
- Qt 之 ActiveX控件跑官方例程记录
- 关于hadoop hdfs中Non DFS Used占用很大的问题分析处理
- isEmpty与isBlank区别
- POJ 1922 Ride to School 题解
- LeetCode (14)Longest Common Prefix
- java 面试1
- JavaScript倒计时
- Linux、GUN/Linux、GUN、GPL以及各个发行版本详细介绍
- python之小错误一
- iOS开发
- C/C++中的关键字static
- 如何获取Android手机连接当前网络的外网IP