自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

不要说话的博客

做自己喜欢的事情

  • 博客(34)
  • 资源 (2)
  • 收藏
  • 关注

原创 poj 动态规划DP - 1664 放苹果

dp[m][n]表示m个苹果放n个盘子里面.此问题可分为两个子问题:当m所以m当m>=n时,可分为两种放法,一种为至少有一个盘子为空,则有dp[m][n-1]种放法。另外为n个盘子都不为空,则先将n个苹果一个一个放入n的盘子中,剩下的m-n个苹果再放入n个盘子中。此放法就相当于m-n个苹果放n个盘子里面,有dp[m-n][n]种放法。所以状态转移方程为dp[i][j]:if(i

2015-04-30 19:41:51 1476

原创 poj 动态规划DP - 1609 Tiling Up Blocks

Michael The Kid有n块积木,每块积木左上有l个凸口,右上有w个凸口,左下右l个凹口,右下有w个凹口。当l >= l'并且m >= m'时,木块'可安装于另一个上面。问最高能叠几层积木。我们用dp[i][j]表示i'dp[i][j]=max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-1])) , 因为最大就是100,所以我们只要输出dp[100][10

2015-04-30 15:39:24 612

原创 poj 动态规划DP - 1458 Common Subsequence

最长公共子序列。DP经典题目。两个字符串a与b,dp[i][j]代表在在a的前i个字符与b的前j个字符公共子序列的最大值。当a的第i个字符与b的第j个字符相等时,最大数等于a的前i-1个字符与b的前j-1个字符最大值+1;否则最大数等于max(a的前i-1个字符与b的前j个字符最大值,a的前i个字符与b的前j-1个字符最大值)。# include# include# define

2015-04-29 21:28:47 519

原创 poj 动态规划DP - 1456 Supermarket

题目大意:每一个商品有自己的价值和保存日期,必须在日期内卖出,要求算出在满足保存日期内所卖出商品的最大价值和。我的做法是,第i件商品在保存日期的每一天内与前i件商品在那天卖出的商品作比较,大于则停止判断,开始判断第i+1件商品。#include#include#include#define max(x,y)(x>y?x:y)#define MAX 10003str

2015-04-29 20:45:57 497

原创 poj 动态规划DP - 2533 Longest Ordered Subsequence

动态规划经典题:最长上升子序列。 假如我们考虑求A[1],A[2],…,A[i]的最长非降子序列的长度,其中i为了方便理解我们是如何找到状态转移方程的,我先把下面的例子提到前面来讲。 如果我们要求的这N个数的序列是:5,3,4,8,6,7根据上面找到的状态,我们可以得到:(下文的最长非降子序列都用LIS表示)前1个数的LIS长度d(1)=1(序列:5)前2

2015-04-28 15:00:58 653

原创 poj 动态规划DP - 1163 The Triangle

这里有一份DP题目列表点击打开链接,大家想专门刷DP的可以看一下。这是一道经典的DP题,找出从顶到底和最大的路径和。我们先记录每个路径点上面的值map[i][j] ,这道题的递推式是map[i][j] = max(map[i-1][j]+map[i][j],map[i-1][j-1]+map[i][j]); 当然最边缘的路径只有一条,单独考虑。# include# d

2015-04-26 22:26:25 510

原创 poj 动态规划DP - 1157 LITTLE SHOP OF FLOWERS

这里有一份DP题目列表点击打开链接,大家想专门刷DP的可以看一下。我们有不同的花和花瓶,每束花在不同的花瓶里有不同的价值,最后找出价值最大的放花顺序。动态规划最重要的是找出递推式,我们将每束花在不同花瓶的价值放在data[i][j]里,map[i][j]表示第i束花插在第1-j号花瓶中全局最大的价值,递推式为:map[i][j] = max(map[i-1][j-1]+data[i][

2015-04-26 18:38:22 508

原创 poj 动态规划DP - 1125 Stockbroker Grapevine

从今天开始刷动态规划类题目,先从简单的开始,这里有一份DP题目列表点击打开链接,大家想专门刷DP的可以看一下。1125题就是一道连通题,股票经纪人之间互传谣言,但是每个人传到其他人的时间不同,求出传播最快的那个人和所需时间。我们可以看出这是一道求最短路径题,所以想起了Floyd算法,由于Floyd算法实现的简单性,所以绝大部分的最短路径题都是由Floyd算法解决的。

2015-04-25 19:52:38 543

原创 poj 并查集 - 2524 Ubiquitous Religions

并查集题目,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。基本上并查集题目都是在大体架构上面加一些东西即可。每个人都可能有不同的信仰,有n个学生,给出一些line,每个line里的两个人信仰一样,最后判断有n个学生中最多有多少信仰。我们在原本模板上加入一个记录信仰数的变量num,一开始num=n,在合并两个有相同信仰的

2015-04-24 20:49:01 520

原创 poj 并查集 - 大体模板

下面是并查集的主要结构代码,即模板:int pa[MAXN]; // 创建集合void make_set(int size) { for(int i=1;i<=size;i++) pa[i] = i;} // 查int find_set(int x) { if(x==pa[x]) return x; pa[x]=find_set(pa[x]); r

2015-04-24 20:29:55 636

原创 poj 并查集 - 2492 A Bug's Life

并查集题目,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。基本上并查集题目都是在大体架构上面加一些东西即可。这道题目和poj 1703 很相似,bug之间只存在两种状态,男 1 和女 0,所以两个被判断是同性的相恋就可疑了(德国人还挺好玩)。在这里这里在并查集模板里加入一个sex数组,用来说明这一个节点的bug是属于男还是女。我们

2015-04-24 20:25:19 502

原创 poj 并查集 - 2236 Wireless Network

并查集题目,点击打开链接这位博主对并查集的介绍可谓是很详细易懂了,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。现在n台之间有距离的电脑,只有距离小于d的才能连接,我们需要修复他们,让彼此之间可以互相连接。这一次我们在并查集模板里面加入ranks数组用来记录该节点的修复情况,在union_set时,如果两台机器都修复了而且距离小于d,

2015-04-24 19:17:07 513

原创 poj 并查集 - 1703 Find them, Catch them

并查集题目,点击打开链接这位博主对并查集的介绍可谓是很详细易懂了,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。这道题目里里面有两个帮派,我们需要判断抓到的两个罪犯,是否属于一个帮派?D [a] [b] 说明a,b不是一个帮派,A[a][b]时需要判断这两个人是不是一个帮派的。这里在并查集模板里加入一个ranks数组,

2015-04-24 13:46:51 469

原创 poj 并查集 - 1308 Is It A Tree?

最近因为保研,在刷一些poj上面的ACM题,发现智商真的是无限被碾压。。。1308 这一道题目考察的是并查集,点击打开链接这位博主对并查集的介绍可谓是很详细易懂了,并的意思就是将两个不同类别的集合合并到一起,类似于两棵树合并;查的意思就是找到这个点所属集合的根节点。并查集的基本模板:int pre[1000 ];int find(int x)

2015-04-23 21:34:32 443

原创 Find Peak Element - LeetCode

Find Peak Element - LeetCode题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.

2015-04-10 20:17:00 681

原创 Generate Parentheses - LeetCode

Generate Parentheses - LeetCode题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((

2015-04-10 19:43:11 544

原创 Trapping Rain Water - LeetCode

Trapping Rain Water - LeetCode 题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For

2015-04-08 15:40:23 596

原创 Container With Most Water - LeetCode

Container With Most Water - LeetCode题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endp

2015-04-07 20:24:01 618

原创 Integer to Roman - LeetCode

Integer to Roman - LeetCode题目:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.分析:这道题目里面的罗马数字含义在Roman to Integer - LeetCode里面

2015-04-07 19:52:22 470

原创 Sort Colors - LeetCode

Sort Colors - LeetCode题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

2015-04-06 22:18:23 519

原创 Jump Game II - LeetCode

Jump Game II - LeetCode题目: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 lengt

2015-04-05 20:32:39 679

原创 Jump Game - LeetCode

Jump Game - LeetCode题目: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 a

2015-04-05 20:28:51 567

原创 一点关于python的小感悟

写了一段时间的python发现,如果之前学习过c这种传统性语言的话,怎么写python都带有c的影子,一些其实很简单的事情,自己总是按照c的思想写,所以觉得python真的适合自己第一门学习的语言,这样再写起来会很方便。(也因为自己写的太少,净给自己写的不好找理由。。)

2015-04-05 16:46:03 671

原创 Best Time to Buy and Sell Stock III - LeetCode

Best Time to Buy and Sell Stock III - LeetCode题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You

2015-04-05 16:38:30 459

原创 Edit Distance - LeetCode

Edit Distance - LeetCode题目:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the followin

2015-04-05 15:28:03 424

原创 Triangle - LeetCode

Triangle - LeetCode题目:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle

2015-04-04 19:48:31 495

原创 House Robber - LeetCode

House Robber - LeetCode题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing e

2015-04-02 23:05:42 757

原创 Unique Paths II - LeetCode

Unique Paths II - LeetCode题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is mar

2015-04-02 19:32:07 657

原创 Minimum Path Sum - LeetCode

Minimum Path Sum - LeetCode题目:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You

2015-04-02 17:13:14 459

原创 Best Time to Buy and Sell Stock - LeetCode

Best Time to Buy and Sell Stock - LeetCode题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one trans

2015-04-02 16:30:25 503

原创 Maximum Subarray - LeetCode

Maximum Subarray - LeetCode题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],

2015-04-02 16:03:11 445

原创 Unique Paths - LeetCode

Unique Paths - LeetCode题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time.

2015-04-02 15:53:38 554

原创 Number of 1 Bits - LeetCode

Number of 1 Bits - LeetCode题目:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer

2015-04-02 13:55:55 489

原创 机器学习笔记 - 贝叶斯学习(5)

贝叶斯置信网如前两节所讨论的,朴素贝叶斯分类器假定了属性a1,a2...ana_1,a_2...a_n的值在给定目标值vv下是条件 独立的。这一假定显著地减小了目标函数学习的计算复杂度。 当此条件成立时,朴素贝叶斯分类器可得到最优贝叶斯分类。然而在许多情形下,这一条件独立假定明显过于严格了。在大多数情况下,属性之间会有一些联系,例如在(4)中最后例子中的属性outloock=sunnyoutlooc

2015-04-01 15:47:03 1765

TVAL3_v1.0.zip

TVAL3的压缩感知算法,可以用于单像素相机的图像重构。

2015-11-30

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除