Advertisement
yuawn

algo2017_week11_divisor

Dec 17th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fo(n) for(int i=0;i<n;i++)
  4. #define fos(o,n) for(int i=o;i<=n;i++)
  5.  
  6. int main(){
  7.  
  8.     int T;
  9.     cin >> T;
  10.        
  11.     while( T-- ){
  12.         int a , b , ans , max = -1;
  13.         cin >> a >> b;
  14.        
  15.         fos( a , b ){
  16.             int now = 0;
  17.            
  18.             for( int j = 1 ; j <= sqrt( i ) ; ++j ) if( !( i % j ) ) now += 2;
  19.            
  20.             if( (int)sqrt( i ) * (int)sqrt( i ) == i ) --now;
  21.             if( now > max ) ans = i , max = now;
  22.         }
  23.        
  24.         printf( "Between %d and %d, %d has a maximum of %d divisors.\n" , a , b , ans , max );
  25.        
  26.     }
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement