Advertisement
Josif_tepe

Untitled

Mar 16th, 2024
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     ios_base::sync_with_stdio(false);
  6.     int a, b;
  7.     cin >> a >> b;
  8.  
  9.     int koren = sqrt(a);
  10.     int res = 0;
  11.     for(int i = 1; i <= koren; i++) {
  12.         if(a % i == 0) {
  13.             if(b % i == 0) {
  14.                 res++;
  15.             }
  16.             int d = a / i;
  17.             if(b % d == 0 and i != d) {
  18.                 res++;
  19.             }
  20.         }
  21.     }
  22.     cout << res << endl;
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement