2 shunfurh shunfurh 于 2017.09.14 14:20 提问

Nonstop Travel


Fast Phil works the late shift and leaves his company's parking lot at precisely 2:00 AM every morning. His route home is by a straight road which has one or more traffic signals. Phil has always wondered if, given the locations and cycles of each of the traffic signals, are there velocities he can travel home without ever having to speed up or slow down on account of a red light. You are to write a program to satisfy his curiosity.

Your program should find all integer speeds (in miles per hour) which can be used for Phil's trip home. Each speed is a rate (in miles per hour) he can maintain the moment he leaves the parking lot at 2:00 AM until he arrives home (we assume Phil has a long driveway in which to decelerate) such that he never passes through a red signal. He is allowed to pass throgh a signal at the exact moment it turns from yellow to red, or at the exact moment a red signal turns green. Since Phil is a relatively law-abiding citizen, you need only consider speeds less than or equal to 60 mph. Likewise, Phil isn't interested in travelling too slowly, so you should not consider speeds lower than 30 mph.

Input will consist of one or more sets of data describing a set of traffic signals, followed by the integer -1. The first integer in each set will contain the value N (specifying the number of traffic signals). N will be no larger than 6. This value will be followed by N sets of numbers, each containing values (in order) for L, G, Y and R. L is a positive real number indicating the location of a traffic signal, in miles, from the parking lot. G, Y and R are the lengths of time (in seconds) of the green, yellow, and red periods of the corresponding traffic signal's cycle. Phil has learned from an informant in the Highway Department that all N traffic signals start their green period precisely at 2:00 AM.

Output should consist of the input case number (starting with 1) followed by a list of all valid integer speeds Phil may drive to avoid the red signals. Consecutive integer speeds should be specified in interval notation of the form L-H, where L and H are the lowest and highest speeds for the interval. Intervals of the form L-L (that is, an interval of length 1) shold just be written as L. Intervals should be separated by commas. If there are no valid speeds, you program should display the phrase No acceptable speeds. The Expected Output below illustrates this format.
Sample Input

5.5 40 8 25

10.7 10 2 75
12.5 12 5 57
17.93 15 4 67

Sample Output

Case 1: 30, 32-33, 36-38, 41-45, 48-54, 59-60
Case 2: No acceptable speeds.


devmiao   Ds   Rxr 2017.09.30 08:32
Csdn user default icon
UVA 617 - Nonstop Travel
对于每一个红绿灯,如果到达时间%(3个灯的周期)都不在红灯的范围里面,那么这个速度就是可行的 #include #include #include #include using namespace std; #define MAX 10 int G[MAX],Y[MAX],R[MAX]; double dis[MAX]; bool speeds[65]; int n; int main(
UVa617 - Nonstop Travel
Nonstop Travel  Fast Phil works the late shift and leaves his company's parking lot at precisely 2:00 AM every morning. His route home is by a straight road which has one or more traffic
POJ 1310 Nonstop Travel 笔记
停止AIX中的pconsole和System Director Agents进程
在AIX 5.3高版本、AIX 6.1和AIX7中,安装完操作系统后,默认有两个java进程会自动启动,如下所示。 # ps -ef | grep java     root 217252 299188   0 02:55:35      -  0:08 /var/opt/tivoli/ep/_jvm/jre/bin/java -Xmx384m -Xminf0.01 -Xmaxf0.4 -Xb
UVA 617 - Nonstop Travel(数论+暴力枚举)
题目链接:617 - Nonstop Travel 题意:给定一些红绿灯,现在速度能在30-60km/h之内,求多少个速度满足一路不遇到红灯。 思路:暴力每一个速度,去判断可不可以,最后注意下输出格式即可 代码: #include #include #include const double esp = 1e-6; int n, vis[105]; struct D { do
uva 617- Nonstop Travel(暴力+数学)
题目链接:uva 617 - Nonstop Travel 题目大意:
It's smarter to travel in group
It's smarter to travel in group.  有个动画的gif,很好玩的,不过太大了,上传不了。 留个链接吧,不知有效期多久哦。 团队的力量是很重要的。
1003. Universal Travel Sites (35)
本题是PAT上顶级一道题目,考察的知识点其实只有一个,最大流问题。用基于广度优先搜索的Edmonds-Karp算法求解。题目意思就是说求解最多能从地球站发送出去的最大人数,在到达目的星球(MAR)上途径每一个行星(不包括MAR)上都没有收留多余游客的能力,到达的游客必须运送出去。那么可以将EAR视为源点s,MAR视为汇点,是一个单源点单汇点的最大流问题。代码如下:// 1003.cpp : 定义控制
[USACO Jan09]安全路径Safe Travel解题报告
题目 http://cojs.tk/cogs/problem/problem.php?pid=279 分析 首先把最短路径树画出来(由题意最短路径唯一,所以是树): 其中1是根。我们将树记作T,i的子树记作B。图中,B是绿色点,T-B是红色点。 而1~i最短路上的最后一条边(也就是不能走的边)即i的父亲边。将这条边去掉以后,1~i的最短路长什么
UVALive 3561 Low Cost Air Travel(多状态最短路,dp)
题目:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1562 题目大意:就是有一些联票,每张票有一些站,每张票你只能从头开始乘,不能不能中途上或者下。现在有一些行程,要按顺序去一些地方。问你怎么样乘花费最小。输出最小值和路径。 解题思路