Advertisement
Plabon_dutta

UVA 294 - Divisors

Apr 22nd, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <math.h>
  3. #include<string>
  4. #define pi acos(-1.0)
  5. #define ll long long int
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     ll t;
  11.     cin >> t;
  12.     while(t--) {
  13.         ll a, b, n=0, nd=0;
  14.         double f=0, c=0;
  15.         cin >> a >> b;
  16.         for(int i=a; i<=b; i++) {
  17.             c=0;
  18.             f=pow(i,0.5);
  19.             for(int j=1; j<=f; j++) {
  20.                 if(i%j==0){
  21.                     c++;
  22.                     if(j<f) c++;
  23.                 }
  24.             }
  25.             if(c>nd) {
  26.                 nd=(int)c;
  27.                 n=i;
  28.             }
  29.         }
  30.         cout << "Between " << a << " and " << b << ", " << n << " has a maximum of " << nd << " divisors.\n";
  31.     }
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement