![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
基本算法
文章平均质量分 62
haoyunsheng_1201
这个作者很懒,什么都没留下…
展开
-
POJ 1007 DNA Sorting
DNA SortingTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 59510 Accepted: 23481DescriptionOne measure of ``unsortedness'' in a sequence is the number o原创 2011-10-27 15:09:35 · 291 阅读 · 0 评论 -
归并排序求逆序数
#include #include #include using namespace std;int cnt;void mergesort(int i,int j,int *a,int *b){ if(j-i>1) { int m=(i+j)/2; mergesort(i,m,a,b); merges原创 2011-10-27 14:11:30 · 290 阅读 · 0 评论 -
区间素数筛选法 joj 1928 Prime Distance
1928: Prime DistanceResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K7223StandardThe branch of mathematics called number theory is about propertie原创 2011-10-31 14:03:03 · 686 阅读 · 1 评论 -
位运算
转载地址:http://www.cnblogs.com/xiaoxian1369/archive/2011/08/11/2134787.html1) int型变量循环左移k次,即a=a >16-k (设sizeof(int)=16) (2) int型变量a循环右移k次,即a=a>>k |a (3)整数的平均值 对于两个整数x,y,如果用 (x+y)/2 求平均值转载 2012-04-20 16:35:31 · 337 阅读 · 0 评论 -
qsort函数使用 P1082找朋友
描述 Description 童年的我们,对各种事物充满了好奇与向往。这天,小朋友们对数字产生了兴趣,并且想和数字交朋友。可是,怎么分配这些数字才能使得每个小朋友都唯一地找到一个数字朋友呢?C小朋友说:咱们按自己名字的字典序先后,依次选择一个剩余的最小的数字当朋友。好么?Q小朋友十分赞同。于是,大家都同意了。 输入格式 Input原创 2010-10-16 18:56:00 · 1003 阅读 · 0 评论 -
归并排序和快速排序
#include #include #include #include void Qsort(int *a,int x,int y){//自顶向下 先求出a[x]的位置if(xint i=x,j=y;while(ii++;while(ij--; //若a只有一个元素,j--后等于x,故到递归出口while(j>x&&a[j]>a[x]) j--;if原创 2012-04-26 10:00:27 · 269 阅读 · 0 评论 -
位运算取反、求绝对值
#include #include #include void swap(int *a,int *b){*a ^= *b; //a = a^b*b ^= *a; //b = a^b = a^b^b = a*a ^= *b; //a = a^b = a^b^a = b//*a^=*b^=*a^=*b}int _abs(int a){int b;原创 2012-04-20 17:17:05 · 2616 阅读 · 0 评论 -
二分查找求上界 下界
#include#include#includeint a[10]={5,5,2,6,5,8,3,8,5,9};int hig_binSearch(int n,int b,int e){//左闭右开 while(e-b>1){ //有一个元素 int m = b+(e-b)/2; i原创 2012-09-19 13:26:27 · 923 阅读 · 0 评论