aurko96

Divisors

Jul 5th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5.     long long i,j,n,k,x,y,z,m,t,p,q,count;
  6.     scanf("%lld",&t);
  7.     for(k=1;k<=t;k++)
  8.     {
  9.         scanf("%lld %lld",&x,&y);
  10.         q=n=0;
  11.         for(i=x;i<=y;i++)
  12.         {
  13.             m=sqrt(i);
  14.             for(j=1,count=0;j<=m;j++)
  15.             {
  16.                 if(i%j==0) count+=2;
  17.                 if(i/j==j) count--;
  18.             }
  19.             if(count>n)
  20.             {
  21.                 q=i;
  22.                 n=count;
  23.             }
  24.         }
  25.         printf("Between %lld and %lld, %lld has a maximum of %lld divisors.\n",x,y,q,n);
  26.     }
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment