Untitled
raw download clone
C
views 20
,
size 742 b
#include<stdio.h>

int factor_counter(int x)
{
     int k,factors=0;
     for(k=1;k*k<x;k++)
     {
          if(x%k==0)factors+=2;
     }
     return factors+(x==k*k);
}

int main(void)
{
     int T;
     int L[21]={0},R[21]={0};
     int fnum=0,num=0;
     int temp;

     scanf("%d",&T);
     for(int i=0;i<T;i++)
     {
          scanf("%d %d",&L[i],&R[i]);
     }

     for(int i=0;i<T;i++)
     {
          fnum=0;
          for(int j=L[i];j<=R[i];j++)
          {
               temp=factor_counter(j);
               if(fnum<temp)
               {
                    fnum=temp;
                    num=j;
               }
          }
          printf("%d\n",num);
     }

     return 0;

}
close fullscreen
Login or Register to edit or fork this paste. It's free.