
Algorithm
文章平均质量分 76
ch209209
这个作者很懒,什么都没留下…
展开
-
pat 1002
还有一个测试用例没有通过,暂存于此。 // pat_test.cpp : 定义控制台应用程序的入口点。 // #define __1002__ENABLE__ #ifdef __1002__ENABLE__ #include "stdio.h" #define MAXN 1000 typedef struct poly{ int exp; float cof;原创 2012-03-24 21:34:51 · 703 阅读 · 0 评论 -
Pascal's Triangle II
http://leetcode.com/onlinejudge#question_118 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your alg原创 2013-07-23 17:04:49 · 574 阅读 · 0 评论 -
Pascal's Triangle --Leetcode
http://leetcode.com/onlinejudge#question_118 Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,原创 2013-07-22 21:18:18 · 598 阅读 · 0 评论 -
积分图
在学习opencv的surf的时候,又一次看到了积分图这个概念,便努力回忆上次是怎么用到它的。记起来了,是在学习人脸检测时,Viola-Jones的文章中提到的。积分图概念的创始人不记得了,但第一次让积分图推广使用的应该就是Viola&Jones了。 在网上看到有人对从SIFT转而想到SURF而感到惊叹的时候,我却觉得根本没什么大不了。俺第一次看到SIFT的时候,就一下子想到可以转载 2013-06-20 10:35:29 · 780 阅读 · 0 评论 -
PAT-1032
1032. Sharing (25) 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1032 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may le原创 2012-11-22 11:56:48 · 630 阅读 · 0 评论 -
PAT-1040
1040. Longest Symmetric String 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1040 Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is原创 2012-11-18 12:16:33 · 583 阅读 · 0 评论 -
PAT-1015
1015. Reversible Primes (20) 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1015 A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For exa原创 2012-11-17 18:31:05 · 593 阅读 · 0 评论 -
PAT -1007
1007. Maximum Subsequence Sum 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1007 Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ...,原创 2012-11-17 13:34:55 · 588 阅读 · 0 评论 -
PAT-1038
1038. Recover the Smallest Number 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1038 Given a collection of number segments, you are supposed to recover the smallest number from them. For example原创 2012-11-17 12:17:14 · 670 阅读 · 0 评论 -
0-1背包问题
背包问题有0-1背包问题和fraction背包问题,前者规定每个物品要么选,要么不选,而fraction knanpsack允许选取一个物品的一部分,0-1背包问题是NP难的,而fraction knapsacks的复杂度是O(n*logn), 只需要将单位物品的价值按降序排列,利用贪心策略选取即可得到最优解。 给定一个背包,容量为C,有n个物品,重量为n维行向量w,价值为n维行向量v. |v|转载 2012-11-15 09:26:03 · 879 阅读 · 0 评论 -
判断一个点是否在给定的凸四边形内
转http://hi.baidu.com/quchenyuan/item/1c50a70306152f3ef3eafc8f 方法一: 如果一个点在这个凸四边形内,那么按照顺时针方向,该点一定在每条边的右侧。可使用矢量叉积来看:该方法只适用于凸多边形。 矢量叉积: 计算矢量叉积是与直线和线段相关算法的核心部分。设矢量P = ( x1, y1 ),Q = ( x2, y转载 2013-08-01 20:35:04 · 2127 阅读 · 0 评论