Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define UI unsigned int
- using namespace std;
- ifstream in("maxd.in");
- ofstream out("maxd.out");
- UI NrDiv(UI x)
- {
- unsigned int e,p,d;
- e=0;
- while(x%2==0)
- {
- x/=2;
- e++;
- }
- p=e+1;
- for(d=3; x>1 && d*d<=x; d+=2)
- {
- e=0;
- while(x%d==0)
- {
- x/=d;
- e++;
- }
- p*=(e+1);
- }
- if(x>1)
- p*=2;
- return p;
- }
- UI minim,nrdiv,contor,a,b,i;
- int main()
- {
- in>>a>>b;
- minim=a;
- nrdiv=NrDiv(a);
- contor=1;
- for(i=a+1; i<=b; i++)
- {
- if(nrdiv<NrDiv(i))
- {
- nrdiv=NrDiv(i);
- minim=i;
- contor=1;
- }
- else
- {
- if(nrdiv==NrDiv(i))
- contor++;
- }
- }
- out<<minim<<" "<<nrdiv<<" "<<contor;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement