今天没有新动态
@kidultff

记忆化搜索--优化斐波那契数列递归函数

记忆化搜索,即在搜索过程中记录下搜索结果,在下次的搜索过程中如果算出过这个结果,就可以直接拿来用。举个栗子:现有一个问题,要求写出一个函数,功能是输出第n个斐波那契数列。斐波那契数列是这样的:1,1,2,3,5,8......直接的办法是开一个数 ...
  • 0
  • 1
@kidultff

PAT-A 真题- 1087. All Roads Lead to Rome

原题干:Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each input file contains one t ...
  • 0
  • 0
@kidultff

PAT-A 真题- 1072. Gas Station

原题干:A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its servic ...
  • 0
  • 0
@kidultff

Bellman-Ford算法求解带负权的最短路径问题

0x00、Dijkstra并不是万能的前面我们讲过了Dijkstra算法,Dijkstra算法可以很好的解决边权均为正数的最短路径问题,但是,请看下图:(上面的点是A,左边的是B,右边的是C,作图的时候忘记打上去了TAT...)如果我们使用Dijkstra来解决从A走向,我 ...
  • 0
  • 2