题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/A题意: 多组案例,先输入数据的数目,在依次输入数据,判断将这些数据从小到大排列最少需要多少操作步数。(案例以输入0结束)案例: Sample Input...
分类:
编程语言 时间:
2015-08-05 17:56:52
阅读次数:
182
原题poj 2299:http://poj.org/problem?id=2299题意,给你一个数组,去统计它们的逆序数,由于题目中说道数组最长可达五十万,那么O(n^2)的排序算法就不要再想了,接下来的选择是快排,归并,看你喜欢了这里列出归并的解法:#include"iostream"using ...
分类:
编程语言 时间:
2015-08-05 12:36:56
阅读次数:
149
利用归并排序统计逆序数,利用归并求逆序在对子序列s1和s2在归并时(s1,s2已经排好序),若s1[i]>s2[j](逆序状况),则逆序数加上s1.length-i,因为s1中i后面的数字对于s2[j]都是逆序的。 1 #include 2 #include 3 int N; 4 int num.....
分类:
编程语言 时间:
2015-08-05 12:30:09
阅读次数:
169
Ultra-QuickSortTime Limit:7000MSMemory Limit:65536KTotal Submissions:48257Accepted:17610DescriptionIn this problem, you have to analyze a particular s...
分类:
编程语言 时间:
2015-08-04 22:43:46
阅读次数:
176
Ultra-QuickSort
Time Limit: 7000MS
Memory Limit: 65536K
Total Submissions: 48121
Accepted: 17553
Description
In this problem, you have to analyze a particular sorting a...
分类:
其他好文 时间:
2015-08-03 16:53:35
阅读次数:
96
归并排序求逆序数Time Limit:7000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uDescriptionIn this problem, you have to analyze a particular sorting algorit...
分类:
编程语言 时间:
2015-08-03 14:15:21
阅读次数:
122
package sort;import java.util.Scanner;public class QuickSort { public static int[] arr; static{ System.out.println("Enter the array to so...
分类:
编程语言 时间:
2015-07-28 00:21:57
阅读次数:
158
The improvedQuicksortmethod of the present invention utilizes two pointers initialized at opposite ends of the array or partition to be sorted and an ...
分类:
其他好文 时间:
2015-07-27 22:40:09
阅读次数:
144
头文件/************************* 交换排序**************************///冒泡排序void BubbleSort(vector &v,int begin,int end);//快速排序void QuickSort(vector & v...
分类:
编程语言 时间:
2015-07-27 18:10:09
阅读次数:
150
1 package com.book.sword_offer; 2 3 import java.util.Arrays; 4 5 public class quicksort_p64 { 6 7 public static void main(String[] args) { 8 ...
分类:
编程语言 时间:
2015-07-26 14:00:02
阅读次数:
135