#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
using namespace std;
// const double eps=1e-6;
bitset<31624> p;
vector<int> prime;
void calc(){
int tmp=31623;
int tmp2=178;
for(int i=2;i<=tmp;i++){
if(!p[i]){
prime.push_back(i);
if(i<=tmp2)
for(int j=i*i;j<=tmp;j+=i)
p[j]=1;
}
}
}
int main(){
calc();
ios::sync_with_stdio(0);
int t;
cin>>t;
while(t--){
int l,u;
cin>>l>>u;
int i,j;
int fans=0,mx;
for(i=l;i<=u;i++){
int tmp=i,tans=1;
// double lgn=log(i);
for(j=0;j<3401&&prime[j]<=sqrt(i)&&prime[j]<=tmp;j++){
int ans=0;
while(tmp%prime[j]==0)
tmp/=prime[j],ans++;
tans*=ans+1;
}
if(tmp>1)
tans*=2;
// cout<<i<<' '<<tans<<endl;
if(tans>fans)
fans=tans,mx=i;
}
cout<<"Between "<<l<<" and "<<u<<", "<<mx<<" has a maximum of "<<fans<<" divisors."<<endl;
}
}
#include <vector>
#include <bitset>
#include <cmath>
using namespace std;
// const double eps=1e-6;
bitset<31624> p;
vector<int> prime;
void calc(){
int tmp=31623;
int tmp2=178;
for(int i=2;i<=tmp;i++){
if(!p[i]){
prime.push_back(i);
if(i<=tmp2)
for(int j=i*i;j<=tmp;j+=i)
p[j]=1;
}
}
}
int main(){
calc();
ios::sync_with_stdio(0);
int t;
cin>>t;
while(t--){
int l,u;
cin>>l>>u;
int i,j;
int fans=0,mx;
for(i=l;i<=u;i++){
int tmp=i,tans=1;
// double lgn=log(i);
for(j=0;j<3401&&prime[j]<=sqrt(i)&&prime[j]<=tmp;j++){
int ans=0;
while(tmp%prime[j]==0)
tmp/=prime[j],ans++;
tans*=ans+1;
}
if(tmp>1)
tans*=2;
// cout<<i<<' '<<tans<<endl;
if(tans>fans)
fans=tans,mx=i;
}
cout<<"Between "<<l<<" and "<<u<<", "<<mx<<" has a maximum of "<<fans<<" divisors."<<endl;
}
}
Comments
Post a Comment