题目链接:http://ac.jobdu.com/problem.php?pid=1004 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
分类:
其他好文 时间:
2017-05-09 19:37:31
阅读次数:
161
详细解释:算法导论/数据结构书 1.链式基数排序 //n个数,每个数有g个关键字//排序:从最后的关键字开始到最前的关键字//分配+收集//每个关键字分配+收集需要n+n时间,而共有g个关键字,时间复杂度为O(2ng),效率很高。//如果用数组,数据集中在一个区间,则区间的长度很长,另外的区间的内存 ...
分类:
编程语言 时间:
2017-05-06 23:05:41
阅读次数:
339
1 const mo=1000000007; 2 var dp:array[-1000..1000]of int64; 3 x,y,a,b:array[-2000..2000]of longint; 4 fac,exf:array[0..2000]of int64; 5 q,time:array[-... ...
分类:
Web程序 时间:
2017-04-24 10:13:07
阅读次数:
259
sort属于C++范畴,在algorithm头文件中,下面直奔主题,给大家一个清晰明了的认识.qsort有C,和C++两个版本. qsort的compare函数原型 //comp ,也就说,如果the first < the second 返回-1;如果the first > the second ...
分类:
其他好文 时间:
2017-04-23 11:59:06
阅读次数:
174
之前几个排序时间复杂度是n方,接下来这几个速度就要比较快了 ShellSort.h 希尔排序 它的做法是: 将间隔的元素看作一个子序列,对其进行插入排序 缩小间隔,继续对子序列排序 直到间隔为1 比如10个元素 将147 10,258,369分别插入排序 然后对13579,2468 10分别插入排序 ...
分类:
编程语言 时间:
2017-04-17 09:13:25
阅读次数:
200
?? sort函数的使用方法 做ACM题的时候,排序是一种常常要用到的操作。假设每次都自己写个冒泡之类的O(n^2)排序,不但程序easy超时,并且浪费宝贵的比赛时间,还非常有可能写错。STL里面有个sort函数,能够直接对数组排序,复杂度为n*log2(n)。使用这个函数。须要包括头文件。 这个函 ...
分类:
其他好文 时间:
2017-04-14 20:52:28
阅读次数:
238
qsort函数、sort函数 (精心整理篇) 先说明一下qsort和sort,只能对连续内存的数据进行排序,像链表这样的结构是无法排序的。 首先说一下, qsort qsort(基本快速排序的方法,每次把数组分成两部分和中间的一个划分值,而对于有多个重复值的数组来说,基本快速排序的效率较低,且不稳定 ...
分类:
其他好文 时间:
2017-04-06 15:53:36
阅读次数:
207
LeetCode很喜欢sum,里面sum题一堆。 1.Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may a ...
分类:
其他好文 时间:
2017-04-03 11:44:47
阅读次数:
179
github: https://github.com/youker-lxy/msort 截图: 对测试模块不是很了解,以下测试函数未实现: test_msort.c 测试 msort.c 的所有函数 test_generate_data.c 测试 generate_data.c 的所有函数 程序中只 ...
分类:
编程语言 时间:
2017-04-01 13:31:08
阅读次数:
159
qsort passes to the comparing function a pointer to the elements it has to compare; since in C there are no templates, this pointer is just brutally c ...
分类:
其他好文 时间:
2017-03-17 19:37:57
阅读次数:
138