欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

2.14英文题面翻译

时间:2023-05-29

描述

N cities named with numbers 1 ..、N are connected with one-way roads、Each road has two parameters associated with it : the road length and the toll that needs to be paid for the road (expressed in the number of coins).
Bob and Alice used to live in the city 1、After noticing that Alice was cheating in the card game they liked to play, Bob broke up with her and decided to move away - to the city N、He wants to get there as quickly as possible, but he is short on cash.

We want to help Bob to find the shortest path from the city 1 to the city N that he can afford with the amount of money he has.

输入

The first line of the input contains the integer K, 0 <= K <= 10000, maximum number of coins that Bob can spend on his way.
The second line contains the integer N, 2 <= N <= 100, the total number of cities.

The third line contains the integer R, 1 <= R <= 10000, the total number of roads.

Each of the following R lines describes one road by specifying integers S, D, L and T separated by single blank characters :

S is the source city, 1 <= S <= ND is the destination city, 1 <= D <= NL is the road length, 1 <= L <= 100T is the toll (expressed in the number of coins), 0 <= T <=100


Notice that different roads may have the same source and destination cities.

输出

The first and the only line of the output should contain the total length of the shortest path from the city 1 to the city N whose total toll is less than or equal K coins.
If such path does not exist, only number -1 should be written to the output.

OpenJudge - 726:ROADS

翻译

描述

N个被从1到N命名的城市之间有一条路相连,每条路有两个参数,一个是路的长度,一个是通过这条路需要缴纳的过路费(用硬币是 的数量来表示)。

Bob和Alice曾经居住在城市1,但知道了Alice在游戏中作弊后,Bob决定搬家,去城市N。他想要尽快到达城市N,但他缺钱。

我们试图帮助Bob找到从城市1到城市N的所有他能承担得起费用的路中最短的那条。

输入

第一行包含一个整数K,0 <= K <= 10000,代表Bob最多能花在过路费上的硬币数量。

第二行包含一个整数N,2 <= N <= 100,,代表城市的总数。

第三行包含一个整数R,1 <= R <= 10000,代表路的总数。

接下来的R行用四个被单个空格分隔的整数S,D,L,T描述了每一条路。

S是起始城市,1 <= S <= N

D是目的城市,1 <= D <= N

L是路的长度,1 <= L <= 100

T是过路费,(用硬币的数量表示),0 <= T <=100

注意不同的路可能有相同的起始和目的城市

输出

输出的第一行也就是唯一一行应该包含过路费小雨或等于K的最短路径的长度,如果这样的路不存在,那么只需要输出-1就可以了。

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。