-
096172
应用方便的OrbMath数学运算库,适用于多种语言()
- 2018-04-05 16:13:55下载
- 积分:1
-
11087 统计逆序对
说明: Description
设a[0…n-1]是一个包含n个数的数组,若在ia[j],则称(i, j)为a数组的一个逆序对(inversion)。
比如 有5个逆序对。请采用类似“合并排序算法”的分治思路以O(nlogn)的效率来实现逆序对的统计。
一个n个元素序列的逆序对个数由三部分构成:
(1)它的左半部分逆序对的个数,(2)加上右半部分逆序对的个数,(3)再加上左半部分元素大于右半部分元素的数量。
其中前两部分(1)和(2)由递归来实现。要保证算法最后效率O(nlogn),第三部分(3)应该如何实现?
此题请勿采用O(n^2)的简单枚举算法来实现。
并思考如下问题:
(1)怎样的数组含有最多的逆序对?最多的又是多少个呢?
(2)插入排序的运行时间和数组中逆序对的个数有关系吗?什么关系?
输入格式
第一行:n,表示接下来要输入n个元素,n不超过10000。
第二行:n个元素序列。
输出格式
逆序对的个数。
输入样例
5
2 3 8 6 1
输出样例
5(Set a[0... N-1] is a n array containing n numbers. If there is a [i] > a [j] i n the case of I < j, then (i, j) is a n inversion pair of a array.
For example, has five reverse pairs. Please use the idea of "merge sorting algorithm" to achieve the statistics of inverse pairs with O (nlogn) efficiency.
The number of inverse pairs of a sequence of n elements consists of three parts:
(1) The number of reverse pairs in the left half, (2) the number of reverse pairs in the right half, (3) the number of elements in the left half is greater than that in the right half.
The first two parts (1) and (2) are implemented by recursion. To ensure the final efficiency of the algorithm O (nlogn), how should the third part (3) be implemented?
Do not use O (n ^ 2) simple enumeration algorithm to solve this problem.)
- 2019-01-07 23:52:06下载
- 积分:1
-
Penalty-Function-Method-
惩罚函数法C语言相关程序
它将有约束最优化问题转化为求解无约束最优化问题:其中M为足够大的正数, 起"惩罚"作用, 称之为罚因子,F(x, M )称为罚函数。(Penalty Function Method C language-related program it would have constrained optimization problem is transformed into solving unconstrained optimization problem: where M is a sufficiently large positive number, from the " punishment" effect, called the penalty factor, F (x, M) called the penalty function.)
- 2020-12-02 01:39:26下载
- 积分:1
-
legendrefit
Legendre polynomial fitting(勒让德多项式拟合)
该算法程序找出N阶勒让德多项式你的的权值系数 (Legendre polynomial fitting (Legendre polynomial fitting) procedures to identify the algorithm N-order Legendre polynomials your weight coefficient)
- 2008-12-27 03:38:23下载
- 积分:1
-
GM2
说明: GM(1,1)灰色模型,便于了解其混沌特性,程序很短,由matlab编译,(GM (1,1) gray model to facilitate understanding of their chaotic behavior, a very short procedure, Matlab Compiler,)
- 2006-04-26 14:53:58下载
- 积分:1
-
GS迭代法
说明: 牛顿迭代法的matlab代码,数值分析中重要的一个算法(Matlab code of Newton iterative method)
- 2019-12-01 10:06:30下载
- 积分:1
-
Expressway-Exit-Data-OD
提出基于高速公路收费站进出口数据推算OD矩阵的一般方法。在缺乏初始OD矩阵的条件下,结合指数平滑法和无约束重力模型思想,通过VB编程反复迭代进行初始OD矩阵推算 利用组合模型预测高速公路各收费站出入口流量,通过弗雷特法进行OD分布推算。以沪宁高速公路为例证实此方法具有较高的精度。(Proposed highway toll station-based import and export data projections general OD matrix method. Lack of initial OD matrix conditions, combined with the exponential smoothing and unconstrained gravity model of thinking, through the VB Programming iterative initial OD Matrix Estimation flow of the use of a combination of model predictions highway toll station entrances and exits through Fratar Method for OD distribution projections. Shanghai-Nanjing Expressway, for example to confirm that this method has higher accuracy.)
- 2013-01-18 11:00:44下载
- 积分:1
-
dpnewton_zuisu
阻尼牛顿法、最速下降法、变尺度法的matlab程序。(Damped Newton' s method, steepest descent method, variable metric method matlab program.)
- 2009-12-27 11:12:52下载
- 积分:1
-
CG
说明: 共轭梯度法求解线性方程组,主要采用FR共轭梯度法(solve liner solutions from CG)
- 2014-04-09 19:51:23下载
- 积分:1
-
log
之前找不到合适精度的log2x函数的定点化源码,经过实现并验证后,发上来大家一起学习(fixed version for log2x)
- 2012-06-27 20:19:22下载
- 积分:1