-
CLMCS
潮流计算中拉丁超立方采样的算法,可利用其进行概率潮流计算(Flow calculation Latin hypercube sampling algorithm, can use its probabilistic load flow calculation)
- 2021-04-06 19:39:02下载
- 积分:1
-
inductor_para_75k
开关电源电感计算案例,buck降压斩波输出电感的参数计算和选型(inductor parameter calculation of switching power supply)
- 2020-10-11 08:57:34下载
- 积分:1
-
全向比幅法测角
该程序为全向比幅法测角程序,并给出了测角误差分析(The program is omnidirectional amplitude ratio angle measuring program, and the angle error analysis is given)
- 2018-04-08 17:50:36下载
- 积分:1
-
for90
薄膜生长蒙特卡洛方法的,适合各种原子的啊啊啊啊啊啊啊(The Monte Carlo method of film growth is suitable for various atoms)
- 2020-08-30 16:18:10下载
- 积分:1
-
11087 统计逆序对
Description
设a[0…n-1]是一个包含n个数的数组,若在i<j的情况下,有a[i]>a[j],则称(i, j)为a数组的一个逆序对(inversion)。
比如 <2,3,8,6,1> 有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, <2,3,8,6,1> 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
-
禁忌算法 C++
禁忌搜索算法是一种全局性邻域搜索算法,模拟人类具有记忆功能的寻优特征。它通过局部邻域搜索机制和相应的禁忌准则来避免迂回搜索,并通过破禁水平来释放一些被禁忌的优良状态,进而保证多样化的有效探索,以最终实现全局优化(Tabu search algorithm)
- 2018-04-13 09:03:34下载
- 积分:1
-
Euler_solver
基于有限体积法的naca0012翼型的无粘绕流计算(Calculation of airfoils based on the finite volume method naca0012 inviscid flow around)
- 2012-06-26 18:34:18下载
- 积分:1
-
PWE-solid--water-or-solid-air-
计算声子晶体固-液和固-气体系,和实验测试吻合,很适应(Suitable for computing phononic crystal solid-liquid and solid and gas, and experimental agreement
)
- 2021-04-20 10:28:50下载
- 积分:1
-
Network
对于给定某一线性时不变网络(不含受控源),根据网络属性及结构,通过编程实现自动生成其关联矩阵A和一个树。(Given a linear time-invariant network (excluding controlled source), according to the network properties and structure of the automatically generated by programming its associated matrix A and a tree.)
- 2013-11-03 18:32:12下载
- 积分:1
-
orbit_integrator
考虑地球J2项摄动的轨道积分器,变步长,基于龙格库塔78阶,(orbital integrator considering the J2 pertubation, based on the Runge-Kutta 78 integrator, use automatic step control)
- 2020-12-07 14:49:21下载
- 积分:1