Advertisement
Farjana_akter

Untitled

Feb 27th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long int divisor(long long int n)
  5. {
  6. long long int div=0,i;
  7. for(i=1; i*i<=n; i++)
  8. {
  9. if(n%i==0)
  10. {
  11. if(n/i==i)
  12. div++;
  13. else
  14. div+=2;
  15. }
  16. }
  17. return div;
  18. }
  19.  
  20. int main()
  21. {
  22. long long int l,r,i,j,k,t,ans,mx=0,a,b,c;
  23. cin>>t;
  24. while(t--)
  25. {
  26. cin>>l>>r;
  27. mx=0;
  28. for(i=l; i<=r; i++)
  29. {
  30. a=divisor(i);
  31. if(a>mx)
  32. {
  33. mx=a;
  34. ans=i;
  35. }
  36. }
  37. cout<<"Between "<<l<<" and "<<r<<", "<<ans<<" has a maximum of "<<mx<<" divisors."<<endl;
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement