上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 74 下一页
摘要: 动态规划问题。 若位于边界,则值为1。否则,f(i,j)=f(i-1,j) + f(i-1,j-1); //杨辉三角 #include<iostream> #include<string> #include<vector> using namespace std; vector<vector<int 阅读全文
posted @ 2024-01-11 18:02 不是孩子了 阅读(12) 评论(0) 推荐(0)
摘要: 动态规划问题:通过把原问题分解成相对简单的子问题的方式来解决复杂问题的方法,体现了以空间换时间的算法思想,这也是其与分治法最大的区别。 动态规划解题思路和方法:求解动态规划问题的思路是定义状态并写出状态转移方程,然后可以采用自顶向下的递归+备忘录方法或者自底向上的填写状态转移表方法。 爬楼梯问题,初 阅读全文
posted @ 2024-01-11 17:49 不是孩子了 阅读(25) 评论(0) 推荐(0)
摘要: vector一/二维数组的定义 C++求最值 迪杰斯特拉算法 //单源最短路径 //BFS单源最短路径适用于无权图 //对于带权图,可以用迪杰斯特拉算法或者Floyd算法求解 //网络延迟时间 #include<iostream> #include<string> #include<vector> 阅读全文
posted @ 2024-01-09 22:02 不是孩子了 阅读(34) 评论(0) 推荐(0)
摘要: DFS&BFS 队列queue unordered_map容器(无序map容器) C++中for auto的用法 //克隆图 #include<iostream> #include<string> #include<unordered_map> #include<vector> #include<q 阅读全文
posted @ 2024-01-09 19:30 不是孩子了 阅读(14) 评论(0) 推荐(0)
摘要: 统计入度出度的问题 注意数组定义初始化问题 //找到小镇的法官 #include<iostream> #include<string> #include<vector> #include<algorithm> #include<cmath> using namespace std; /** * 特别 阅读全文
posted @ 2024-01-09 16:18 不是孩子了 阅读(12) 评论(0) 推荐(0)
摘要: 注意数据类型不要溢出 //因子化简 #include<iostream> #include<string> #include<vector> #include<algorithm> #include<cmath> using namespace std; //判断是否是素数 bool is_prim 阅读全文
posted @ 2024-01-08 16:36 不是孩子了 阅读(86) 评论(0) 推荐(0)
摘要: //仓库规划 #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int main() { //N表示仓库个数,M表示位置编码的维数 int N, M, t1, t 阅读全文
posted @ 2024-01-07 22:36 不是孩子了 阅读(32) 评论(0) 推荐(0)
摘要: //二分查找 #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int search(vector<int>& nums, int target) { int l 阅读全文
posted @ 2024-01-07 17:39 不是孩子了 阅读(10) 评论(0) 推荐(0)
摘要: //三数之和 #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; vector<vector<int>> threeSum(vector<int>& nums) { 阅读全文
posted @ 2024-01-07 16:00 不是孩子了 阅读(10) 评论(0) 推荐(0)
摘要: //最接近的三数之和 #include<iostream> #include<string> #include<vector> #include<cmath> #include<algorithm> using namespace std; //双指针 int threeSumClosest(vec 阅读全文
posted @ 2024-01-07 15:14 不是孩子了 阅读(32) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 74 下一页