摘要: 其实这题和北航的oj上的一题一样,北航上的是汉语,题意就不说了,可以看一下北航上的翻译。http://www.bianchengla.com/course/cpp/practise/problem?id=1243直接递归会重复计算一些值,这样就会超时,最好的方法就是用记忆化搜索,用数组将值记录下来,当搜到已经计算过的值时直接使用就行了,避免再一次递归计算,这样会节省很多时间。代码:View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream> 阅读全文
posted @ 2013-02-19 20:00 Misty_1 阅读(333) 评论(0) 推荐(0) 编辑