翻译1.20Repairing a Road

原网址:Repairing a Road - C语言网

题目描述

You live in a small town with R bidirectional roads connecting C crossings and you want to go from crossing 1 to crossing C as soon as possible.

//你住在一个小镇,这个小镇有R条双向路连接着C个十字路口。现在你想以最短时间从路口1到路口C。

You can visit other crossings before arriving at crossing C, but it’s not mandatory.

 //在到达C之前你可以穿过其他路口,但这不是强制的(可穿可不穿)

You have exactly one chance to ask your friend to repair exactly one existing road, from the time you leave crossing 1.

//你只有一次机会让你的朋友修已经存在的路中的一条,但这次机会要在离开路口1后使用。

If he repairs the i-th road for t units of time, the crossing time after that would be viai-t. It's not difficult to see that it takes vi units of time to cross that road if your friend doesn’t repair it.

 //如果你的朋友花费t时间修第i条路,穿过时间会变成viai-t。不难看出,不修路通过的时间是vi.

You cannot start to cross the road when your friend is repairing it.

//你朋友还在修路的时候你就可以出发了

输入

 There will be at most 25 test cases. Each test case begins with two integers C and R (2<=C<=100, 1<=R<=500).

//最多25个测试样例。每个测试样例有两个整数C和R(2<=C<=100, 1<=R<=500)

Each of the next R lines contains two integers xiyi (1<=xiyi<=C) and two positive floating-point numbers vi and ai (1<=vi<=20,1<=ai<=5), indicating that there is a bidirectional road connecting crossing xi and yi, with parameters vi and ai (see above).

//接下来的R行每一行包括两个整数xiyi (1<=xiyi<=C) 和两个正浮点数vi 和 ai (1<=vi<=20,1<=ai<=5),表示这是一条连接xi和yi的路,带有参数vi和ai

Each pair of crossings can be connected by at most one road. The input is terminated by a test case with C=R=0, you should not process it.

//每一个接口最多连接一条路。输入以00结束

输出

 For each test case, print the smallest time it takes to reach crossing C from crossing 1, rounded to 3 digitsafter decimal point. It’s always possible to reach crossing C from crossing 1.

//每组样例,输出从1到C的最短时间,精确到小数点后3为。保证总能从1到C。

样例输入复制
<span style="color:#333333"><span style="color:#333333">3 2
1 2 1.5 1.8
2 3 2.0 1.5
2 1
1 2 2.0 1.8
0 0
</span></span>
样例输出复制
<span style="color:#333333"><span style="color:#333333">2.589
1.976</span></span>
一些单词:

Bidirectional 双向的

Mandatory     强制的

Existing      现存的

Unit          穿越的时间s

Integer       整数

Parameter     参数,限制因素,决定因素

                                                                                                        

 

                                                                                                                        
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值