Advertisement
Josif_tepe

Untitled

Feb 16th, 2024
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x, y;
  7.     cin >> x >> y;
  8.    
  9.     int koren_x = sqrt(x);
  10.     int zaednicki_deliteli =0 ;
  11.     for(int i = 1; i <= koren_x; i += 1) {
  12.         if(x % i == 0) {
  13.             if(y % i == 0) {
  14.                 zaednicki_deliteli += 1;
  15.             }
  16.             if(i != x / i) {
  17.                 if(y % (x / i) == 0) {
  18.                     zaednicki_deliteli += 1;
  19.                 }
  20.             }
  21.         }
  22.     }
  23.     cout << zaednicki_deliteli << endl;
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement