Moderator: Board moderators
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define GI ({int _t; scanf("%d", &_t); _t;})
#define FOR(i, a, b) for (long long int i=a; i<b; i++)
#define REP(i, a) FOR(i, 0, a)
int main() {
int ca ;
cin>>ca;
while (ca--) {
long int res = -1, max = -1;
long int a, b;
cin >> a >> b;
if (a==1 && b==1) {
printf("Between 1 and 1, 1 has a maximum of 1 divisors.\n");
continue;
}
FOR(i, a, b+1) {
int t = 0;
FOR(j, 1, sqrt(i)) {
if (i%j==0) t++;
}
t*=2;
if (sqrt(i)*sqrt(i) == i) t++;
if (t >max ) {
res = i; max = t;
}
}
printf("Between %lld and %lld, %lld has a maximum of %lld divisors.", a, b, res, max);
if(ca>0)cout<<endl;
}
return 0;
}
int divisors (long int c) {
long int s;
int i, j, flag;
int divisornum = 1;
i = 0;
flag = 0;
for(j=0;j<k;j++)
{
factor[j] = 0;
}
k = 0;
if(c<0)
{
c = - c;
}
s = sqrt(c);
while((c>=prime[i] && prime[i]<=s) && c!=1) //prime is an array which hold the prime number
{
j = 0;
while((c%prime[i])==0)
{
flag = 1;
c = c/prime[i];
j++;
}
if(flag==1)
{
factor[k] = j; //save the power of a prime factor to another array
k++;
}
flag = 0;
i++;
}
if(c>1)
{
factor[k] = 1;
k++;
}
for(j=0;j<k;j++)
{
divisornum = divisornum * (factor[j]+1); //applying the process which I describe earlier
}
return divisornum;
}5
1 0
1 1
2 2
3 3
12 18
Between 1 and 1, 0 has a maximum of 2 divisors.
Between 1 and 1, 1 has a maximum of 1 divisors.
Between 2 and 2, 2 has a maximum of 2 divisors.
Between 3 and 3, 3 has a maximum of 2 divisors.
Between 12 and 18, 12 has a maximum of 6 divisors.
Users browsing this forum: No registered users and 1 guest