Maruf_Hasan

divissss

Oct 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define M 1000000
  5. bool mark[M];
  6. vector<int>prime;
  7.  
  8.  
  9. void sieve()
  10. {
  11. int i,j;
  12. prime.push_back(2);
  13. for(i=3;i*i<M;i+=2)
  14. {
  15. if(mark[i]==false)
  16. {
  17. for(j=i*i;j<M;j+=2*i)
  18. mark[j]=true;
  19. }
  20. }
  21. for(i=3;i<M;i+=2)
  22. {
  23. if(mark[i]==false)
  24. prime.push_back(i);
  25. }
  26.  
  27. }
  28. int divisor(int n)
  29. {
  30. int i,val,count,sum;
  31. val=sqrt(n)+1;
  32. sum=1;
  33. for(i=0;prime[i]<val;i++)
  34. {
  35. if(n%prime[i]==0)
  36. {
  37. count=0;
  38. while(n%prime[i]==0)
  39. {
  40. n/=prime[i];
  41. count++;
  42. }
  43. sum*=(count+1);
  44. }
  45. }
  46. if(n>1)
  47. sum*=2;
  48. return sum;
  49. }
  50.  
  51. int main()
  52. {
  53. sieve();
  54. int a,b,i,mx=1;
  55. scanf("%d %d",&a,&b);
  56. for(i=a;i<=b;i++)
  57. {
  58. int k=divisor(i);
  59. if(k>mx)
  60. {
  61. mx=i;
  62. }
  63. }
  64. cout<<mx<<endl;
  65.  
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment