Advertisement
Guest User

problmea

a guest
Jul 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n,maxnrdiv=-1,maxx=0,nr,p=0;
  9.  
  10.     cin>>n;
  11.  
  12.     for(int i=1; i<=n; i++)
  13.     {
  14.         int copie=i,d=2,p=0;
  15.         nr=1;
  16.  
  17.         while(copie!=1)
  18.         {
  19.             while(copie%d==0)
  20.             {
  21.                 p++;
  22.                 copie/=d;
  23.             }
  24.                 nr=nr*(p+1);
  25.                 p=0;
  26.  
  27.             d++;
  28.             if(copie>1 && d * d > copie){
  29.                         d = copie;
  30.                     }
  31.  
  32.         if(nr>maxnrdiv)
  33.         {
  34.             maxnrdiv=nr;
  35.             maxx=i;
  36.         }
  37.  
  38.     }
  39.     }
  40.  
  41.     cout<<maxx;
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement