随笔分类 -  算法题

第二轮复习 包括 九度, POJ, Leetcode 一共100+ 题目, 时间 14/4/3 - 14/4/12
摘要:题目描述思路1. dp[i][j] 表示前 i 个操作中有 j 个入栈操作的方案数2. dp[i][j] = dp[i-1][j-1] + dp[i-1][j], 其中 j >= i/2.3. 为了方便起见, 非法的状态为 0, 比如 dp[3][1] = 0代码/* * source.cpp * * Created on: 2014-4-4 * Author: vincent *//* * dp[i][j] 前 i 个操作中有 j 个入栈操作的种类 * dp[i][j] = dp[i-1][j-1] + dp[i-1][j] * 其中, (i-j) #include #inclu... 阅读全文
posted @ 2014-04-04 20:47 周卓 阅读(302) 评论(0) 推荐(0)
摘要:题目描述总结1. 用 BFS 实现 Dijkstra. 要点是, visited 后标记, 把某个点从优先队列取出后再标记代码 未通过九度测试 RE/* * source.cpp * * Created on: 2014-4-4 * Author: vincent */#include ... 阅读全文
posted @ 2014-04-04 20:12 周卓 阅读(209) 评论(0) 推荐(0)
摘要:题目描述总结1. '_' 运算符不是 a*10 + b, 而是 a*(10 or 100) + b2. char * 与 string 的相互转化char* = string.c_str()string = char*3. 中缀表达式转后者表达式 参考:http://www.cnblogs.com/xinsheng/p/3591781.html4. 通用的中缀转后缀, 用 string 存数据比较好代码 未通过九度测试#include #include #include #include #include #include #include #include #include 阅读全文
posted @ 2014-04-03 11:19 周卓 阅读(292) 评论(0) 推荐(0)
摘要:题目描述总结1. 将数字转化成 string 和字符串sprintf(char*, "%d", int)string = char*, 可以直接赋值2. std::sort 的比较函数写法bool cmp(const &int, const &int)3. 能用库函数, 尽量用库函数, 能减少错误代码未通过九度测试#include #include #include #include #include #include using namespace std;int n;int arr[1000];bool cmp(const int &a, con 阅读全文
posted @ 2014-04-03 09:26 周卓 阅读(180) 评论(0) 推荐(0)