VC++算法动态规划的问题 题目我都不是很明白 求高人解答

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:42:22
Description

Citizens of Byteland adore all sports in which logical thinking is as important as physical skills. One of these sports is crossing the Hex River – the widest river in Byteland. There are n poles numbered 1…n (from left to right) stretching across the river. The citizens have to cross the river by going from the left bank to one pole perhaps to another and so on

and then to the right bank. The left bank is located one pole to the left of pole 1; the right bank is located one pole to the right of pole n.

At time 0, the citizen is on the left bank of the Hex River with the goal of reaching the right bank of the river as quickly as possible. At any given time, each pole is either up or down and the citizen is standing on a pole or standing on a bank of the river. A citizen can stand on a pole only if it is up; such a pole is available.

Each pole is down at time 0 and then spends a time units up, b time units down, a time units up

一条河,左右两岸,n个pole(不知道具体应该叫什么),左岸和第一个pole相连,右岸和第n个pole相连。。

每个pole有up和down两种状态,在a时间内up,然后b时间内down,然后a时间内up,然后b时间内down.......就这么交替循环。人在pole为up时可以踏上去,down时不能。(类似于fc游戏里面传送板,一会消失一会儿出现)。每到一个pole上你可以跳到它前后的5个里面的任意一个上,包括河岸。。比如如果在第5个pole上,你就可以再下一个单位时间转移到1,2,3,4,5(包括当前pole),6,7,8,9,10或者左岸(注意有左岸)上去。

现在需要你在最短的时间里从左岸到达右岸,输出这个最短时间(如果可能过河的话,不可能则输出“NO”)。

输入的第一个数(上面的2)表示总共要做多少次,也就是说比如是2,就会给你两个不同的情况,算完了一种再算一种才结束。

接下来的数n(上面的10),表示有多少个pole。

在接下来有n行,每行有两个数,代表每个pole up和down的时间长短,也就是前面提到的a和b。。

还有什么不明白的么。。?