Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int nod(int a, int b);
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.    
  13.     if (n == 1)
  14.         cout << 1;
  15.     else
  16.     {
  17.         int c = 0;
  18.  
  19.         int l = round(sqrt(n));
  20.         for (size_t i = 1; i <= l; i++)
  21.         {
  22.             if (n % i == 0)
  23.             {
  24.                 if (nod(i, n / i) == 1)
  25.                     c++;
  26.             }
  27.         }
  28.  
  29.         cout << c * 2;
  30.     }
  31. }
  32.  
  33. int nod(int a, int b)
  34. {
  35.     for (int i = a; i > 0; i--)
  36.     {
  37.         if (a % i == 0 && b % i == 0)
  38.         {
  39.             return i;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement