随笔分类 - 数据结构与算法
RT~
摘要:http://www.ibm.com/developerworks/cn/linux/l-openssl.htmlOpenSSL API 的文档有些含糊不清。因为还没有多少关于 OpenSSL 使用的教程,所以对初学者来说,在 应用程序中使用它可能会有一些困难。那么怎样才能使用 OpenSSL 实现...
阅读全文
摘要:题目来源:http://poj.org/problem?id=1037读半天才把题读懂题意是Richard要给房子做栅栏,一个栅栏由N个木板(长度单位依次是1、2、3...N)组成,此栅栏的木板顺序为(a1、a2....aN)且满足下列条件:1、 (ai − ai−1)*(ai − ai+1) > 0 ,(any i; 1 < i < N),也就是说任一一个木板比他相邻的两个木板都高或者都低。也可以理解为以木板高度波浪形排列显然,N个木板可以组成若干个这样的栅栏,现在给栅栏也排个序,比如存在栅栏A(a1,a2,a3....aN)和栅栏B(b1,b2,b3...bN) (括号里
阅读全文
摘要:方便做针对性练习1.搜索 //回溯2.DP(动态规划)3.贪心4.图论 //Dijkstra、最小生成树、网络流5.数论 //解模线性方程6.计算几何 //凸壳、同等安置矩形的并的面积与周长7.组合数学 //Polya定理8.模拟9.数据结构 //并查集、堆10.博弈论1、 排序1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1840, 2201, 2376, 2377, 2380, 1318, 1877, 1928, 1971,1974, 1990, 2001, 2002, 2092, 2379,1002(需要字符处理,排序用快排即可) 100
阅读全文
摘要:转载请注明出处:http://www.cnblogs.com/ligun123/archive/2013/04/01/2993966.htmlThere is an integer arraydwhich does not contain more than two elements of the same value. How many distinct ascending triples (d[i] < d[j] < d[k], i < j < k) are present?Input formatThe first line contains an integer
阅读全文
摘要:转载注明出处:http://www.cnblogs.com/ligun123/archive/2013/03/27/2984740.html题目来源:https://www.hackerrank.com/challenges/medianThe median of M numbers is defined as the middle number after sorting them in order if M is odd or the average number of the middle 2 numbers (again after sorting) if M is even. You
阅读全文
摘要:转载注明出处 http://www.cnblogs.com/ligun123/archive/2013/03/19/2969477.html题目来源:https://www.hackerrank.com/challenges/billboardsBillboardsADZEN is a very popular advertising firm in your city. In every road you can see their advertising billboards. Recently they are facing a serious challenge , MG Road t
阅读全文
摘要:转载注明出处 http://www.cnblogs.com/ligun123/archive/2013/03/19/2969438.html先是跟着Hackerrank练习了下插入排序然后又做了Pairs,来源:https://www.hackerrank.com/challenges/pairsGiven N numbers [N<=10^5], count the total pairs of numbers that have a difference of K. [K>0 and K<1e9]. Each of the N numbers will be > 0
阅读全文
摘要:转载注明出处http://www.cnblogs.com/ligun123/archive/2013/03/13/2957938.html原题:https://www.hackerrank.com/challenges/walking-on-gridsWalking on GridsThere is a N * N matrix. At first you are at the upper left corner (0,0) and you want to get to the lower right corner (N - 1, N - 1). You can only walk down
阅读全文
摘要:一.十一种通用滤波算法(转)1、限幅滤波法(又称程序判断滤波法)A、方法: 根据经验判断,确定两次采样允许的最大偏差值(设为A) 每次检测到新值时判断: 如果本次值与上次值之差<=A,则本次值有效 如果本次值与上次值之差>A,则本次值无效,放弃本次值,用上次值代替本次值B、优点: 能有效克服因偶然因素引起的脉冲干扰C、缺点 无法抑制那种周期性的干扰 平滑度差2、中位值滤波法A、方法: 连续采样N次(N取奇数) 把N次采样值按大小排列 取中间值为本次有效值B、优点: 能有效克服因偶然因素引起的波动干扰 对温度、液位的变化缓慢的被测参数有良好的滤波效果C、缺点: 对流量、速度等快速变化
阅读全文
摘要:经典的八数码问题,有人说不做此题人生不完整,哈哈。状态总数是9! = 362880 种,不算太多,可以满足广搜和A*对于空间的需求。状态可以每次都动态生成,也可以生成一次存储起来,我用的动态生成,《组合数学》书上有一种生成排列的方法叫做"序数法",我看了一会书,把由排列到序数,和由序数到排列的两个函数写了出来,就是代码中的int order(const char *s, int n) 和void get_node(int num, node &tmp)两个函数。启发函数,用的是除空格外的八个数字到正确位置的网格距离。几种方法的比较:广搜,效率最低,500ms;A*,
阅读全文