![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
文章平均质量分 50
Felix_CY
这个作者很懒,什么都没留下…
展开
-
qsort函数用法
转自http://www.cnblogs.com/syxchina/archive/2010/07/29/2197382.html qsort 功 能: 使用快速排序例程进行排序 用 法: void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *));转载 2016-10-30 19:53:13 · 258 阅读 · 0 评论 -
矩阵翻硬币 蓝桥杯
转自http://blog.csdn.net/snailset/article/details/26752435 题目: 小明先把硬币摆成了一个 n 行 m 列的矩阵。 随后,小明对每一个硬币分别进行一次 Q 操作。 对第x行第y列的硬币进行 Q 操作的定义:将所有第 i*x 行,第 j*y 列的硬币进行翻转。 其中i和j为任意使操作可行转载 2016-11-02 10:55:04 · 245 阅读 · 0 评论 -
归并排序
归并排序算法复杂度为nlogn。 算法思想是: 1. 划分问题:把序列分为元素个数尽量相等的两半 2 递归求解:把两半元素分别排序 3 合并问题:把两个有序表合成为一个 先递归的分解数列,再合并数列就完成了归并排序。 http://blog.csdn.net/morewindows/article/details/6678165/原创 2017-02-07 17:28:23 · 216 阅读 · 0 评论 -
动态规划(一)
01背包问题,是用来介绍动态规划算法最经典的例子,网上关于01背包问题的讲解也很多,我写这篇文章力争做到用最简单的方式,最少的公式把01背包问题讲解透彻。 01背包的状态转换方程 f[i,j] = Max{ f[i-1,j-Wi]+Pi( j >= Wi ), f[i-1,j] } f[i,j]表示在前i件物品中选择若干件放在承重为 j 的背包中,可以取得的最大价值。 Pi转载 2016-10-26 21:37:55 · 297 阅读 · 0 评论 -
完全背包问题
01背包问题前面分析过01背包问题。01背包:在M件物品中取出若干件物品放到背包中,每件物品对应的体积v1,v2,v3,....对应的价值为w1,w2,w3,,,,,每件物品最多拿一件。解决方法是 动态规划决策是:第i件物品放或者不放由此得到状态转移方程: f[i,j] = max{f[i-1,j], f[i-1,j-wi]+Pi(j>=wi)}f[i,j]表示前i件物品中选择若干件放...原创 2018-03-30 21:24:02 · 701 阅读 · 1 评论 -
【LeetCode】[55] Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if yo...原创 2018-08-19 22:10:24 · 138 阅读 · 0 评论 -
【Leetcode】[53] Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanati...原创 2018-08-19 22:42:29 · 154 阅读 · 0 评论