2012年8月18日

NOJ coder的音乐烦恼--字符串处理

摘要: http://acm.nit.net.cn/showproblem.jsp?pid=1366View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<string> 4 #include<cmath> 5 6 using namespace std; 7 8 int const ic_max = 5001; 9 10 struct stuNode 11 { 12 int iPriority;//优先级 13 string strSong;//歌曲名 14 }; 15 16 vo 阅读全文

posted @ 2012-08-18 14:51 zimulala 阅读(184) 评论(0) 推荐(0)

2012年8月16日

快速排序

摘要: 在冒泡排序中,一次扫描只能确保最大数值的数移到正确位置,而待排序序列的长度可能只减少1。 快速排序是对冒泡排序的一种本质改进。 基本思想:通过一趟扫描后,使得排序序列的长度能大幅度地减少。快速排序通过一趟扫描,就能确保某个数(以它为基准点吧)的左边各数都比它小,右边各数都比它大。然后又用同样的方法处理它左右两边的数,直到基准点的左右只有一个元素为止。 快速排序:不稳定,时间复杂度 最理想 O(nlogn) 最差时间O(n^2)View Code 1 #include<iostream> 2 #include<cstring> 3 4 using namespace st 阅读全文

posted @ 2012-08-16 16:29 zimulala 阅读(279) 评论(0) 推荐(0)

2012年8月14日

NOJ--希尔排序

摘要: http://acm.nit.net.cn/showproblem.jsp?pid=1494用cin、cout会超时View Code #include<iostream>#include<algorithm>#include<cstring>using namespace std;int const ic_limit = 3000002;int iArr[ic_limit];void vInput(int iN);void vShellSort(int iN);void vOutput(int iN);int main(){ int iN; while(s 阅读全文

posted @ 2012-08-14 18:42 zimulala 阅读(260) 评论(0) 推荐(0)

2012年8月6日

Codeforces--Little Elephant and Sorting

摘要: http://codeforces.com/problemset/problem/205/B例如2 7 3 5 10只需要7-3的步骤View Code 1 #include<iostream> 2 3 using namespace std; 4 5 int const ic_max = 100001; 6 7 long long int iGetMinMoveNum(int iN,int iArr[]); 8 9 int main()10 {11 int iNum;12 long long int iAns;13 int iArr[ic_max];14 1... 阅读全文

posted @ 2012-08-06 15:34 zimulala 阅读(219) 评论(0) 推荐(0)

导航