Advertisement
myloyo

8.1.3-3

Nov 28th, 2022 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7. int f(int n) {
  8.     int d = 2;
  9.     for (int i = 2; i < sqrt(n); i++) {
  10.         if (n % i == 0) {
  11.             d += 2;
  12.         }
  13.     }
  14.     return d;
  15. }
  16.  
  17. int main()
  18. {
  19.     int a, b, maxim;
  20.     cin >> a >> b;
  21.     cout << f(6) << endl;
  22.     maxim = -10000000000000;
  23.     for (int i = a; i <= b; i++) {
  24.         if (f(i) > maxim) {
  25.             maxim = f(i);
  26.         }
  27.     }
  28.     for (int i = a; i <= b; i++) {
  29.         if (f(i) == maxim) {
  30.             cout << i << " ";
  31.         }
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement