A mathematical analysis
two-correlation principle
https://m.baike.so.com/doc/3567228-3751425.html
Three practical exercises
most divisor problem
Problem description: The divisor of a positive integer x is a positive integer that can divide x evenly. The number of divisors of a positive integer x is recorded as div(x). For example, 1, 2, 3, and 10 are all divisors of the positive integer 10, and div(10)=4. Suppose a and b are two positive integers, a<=b, find the number x between a and b with the largest number of divisors.
The following demonstrates the implementation in C language
1. A function that generates prime numbers
void primes(){
bool get [MAXP+1];
for(int i=2;i<=MAXP;i++)
get[i]=ture;
for(i=2;i<=MAXP;i++)
if(get[i]){
int j=i+1;
while(j<=MAXP){
get[j]=false;
j+=i;
}
}
for(int ii=2,j=0;ii<=MAXP;ii++)
if(get[ii]){
prim[++j]=ii;
}
2. Search for the function with the most divisors
void search(int from,int tot,int num,int low,int up){
if(num>=1)
if((tot>max)||((tot==max)&&(num<numb))){
max=tot;
numb=num;
}
if((low==up)&&(low>num))
search(from,tot*2,num*low,1,1);
for(int i=from;i<=PCOUNT;i++){
if(prim[i]>up)
return;
else{
int j=prim[i],x=low1,y=up,n=num,t=tot,m=1;
while(ture){
m++;
t+=tot;
x/=j;
y/=j;
if(x==y)
break;
n*=j;
search(i+1,t,n,x+1,y);}
}
m=1<<m;
if(tot<max/m)
return;
}
}
3. Main function
int main(){
primes();
cin>>l>>u;
if((l==1)&&(u==1)){
max=1;
numb=1;
}
else{
max=2;
numb=1;
search(1,1,1,l,u);
}
cout<<max<<end1;
return 0;
}