Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int t;
  7.     cin >> t;
  8.     for (int w = 0; w < t; w++)
  9.     {
  10.         int a, b;
  11.         cin >> a >> b;
  12.  
  13.         int num = 0;
  14.  
  15.         if (b % a == 0)
  16.         {
  17.             num++;
  18.             int c = b / a;
  19.             for (int i = 2; i * i <= c; i++)
  20.             {
  21.                 while (c % i == 0)
  22.                 {
  23.                     num++;
  24.                     c /= i;
  25.                 }
  26.             }
  27.             if (c != 1)
  28.                 num++;
  29.         }
  30.  
  31.         cout << num << endl;
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement