摘要: #include<iostream> using namespace std; int n,a[1000001]; void qsort(int l,int r) { //应用二分思想 int mid=a[(l+r)/2];//中间数 int i=l,j=r; do { while(a[i]<mid 阅读全文
posted @ 2022-04-17 18:21 半喜 阅读(130) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; long long a[500010],arr[500010];//如果数组范围太小,记得改 int merge(int l,int r) { int p=(l+r)/2,i=0; if(l<r) { merge(l,p 阅读全文
posted @ 2022-04-17 15:33 半喜 阅读(38) 评论(0) 推荐(0)
摘要: void random(int a,int b) { int t; t=(rand()%(b-a+1))+a; return t; } //该函数用于随机取a~b的任意数 rand()可以生成0~32767(windows),0~2147483647(Linux) 头文件为 #include<cst 阅读全文
posted @ 2022-04-16 22:15 半喜 阅读(96) 评论(0) 推荐(0)
摘要: int partition(int p,int r) { int low,high; low=p; high=r; int temp; temp=a[low]; while(low<high) { while(low<high&&a[high]>=temp) //从后面扫描 high--; a[lo 阅读全文
posted @ 2022-04-16 21:15 半喜 阅读(107) 评论(0) 推荐(0)