fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. long long l,u,j,i,divisor,max,num;
  9. cin>>t;
  10. while(t--)
  11. {
  12. scanf("%lld %lld",&l,&u);
  13. max=0;
  14. if(l==1&&u==0)
  15. {
  16. printf("Between 1 and 1, 0 has a maximum of 2 divisors\n");
  17.  
  18. }
  19. for(i=l;i<=u;i++)
  20. {
  21. divisor=0;
  22. int p=sqrt(i);
  23. for(j=1;j<=p;j++){
  24. if(i%j==0){
  25. divisor++;
  26. if(i/j!=j){
  27. divisor++;
  28. }
  29. }
  30. if(max<divisor){
  31. max=divisor;
  32. num=i;
  33. }
  34. }
  35. }
  36. printf("Between %lld and %lld, %lld has a maximum of %lld divisors\n",l,u,num,max);
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0.12s 3464KB
stdin
3
1 10
1000 1000
999999900 1000000000
stdout
Between 1 and 10, 6 has a maximum of 4 divisors
Between 1000 and 1000, 1000 has a maximum of 16 divisors
Between 999999900 and 1000000000, 999999924 has a maximum of 192 divisors