ull hash(char *str){
ull hash = 0, i = 0;
while(str[i]){
hash = (hash<<5) + str[i++] - 'a' + 1;
}
return hash;
}
ull gethash(char *str, int *len){
ull hash = 0, i = 0;
int seed = 1313;
while (str[i]){
hash = hash * seed + str[i++];
}
*len = i;
return hash;
}
//滚动hash
void setDNA(char *dna)
{
unsigned long long hash = 0;
unsigned long long p = 1;
int seed = 1313;
for(int i = 0; i < frg_len; i++){
p = p * seed;
hash = hash * seed + dna[i];
}
insert_hash(hash);
for(int i=1;i<=dna_len-frg_len;i++){
hash = hash * seed - dna[i - 1] * p + dna[i + frg_len - 1];
insert_hash(hash);
}
}
//快速排序
void quicksort(int left, int right){
int i,j,t,temp;
if(left>=right){
return;
}
temp=a[left];
i=left;
j=right;
while(i!=j){
while(a[j]>=temp && i<j)
j--;
while(a[i]<=temp && i<j)
i++;
if(i<j){
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
a[left]=a[i];
a[i]=temp;
quicksort(left,i-1);
quicksort(i+1,right);
}