Facebook
From gherg, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 165
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     ios_base::sync_with_stdio(false);
  6.     cin.tie(NULL);
  7.     long long t;
  8.     cin >> t;
  9.     while (t--)
  10.     {
  11.         long long a,b,l;
  12.         cin>>a>>b>>l;
  13.         long long x = 1;
  14.         set<long long> h;
  15.         for(long long i = 0;i<100;i++){
  16.             if(x>l) break;
  17.             if(l%x) continue;
  18.             long long r = l/x;
  19.             long long y = 1;
  20.             for(long long j = 0;j<100;j++){
  21.                 if(y>r) break;
  22.                 if(r%y) continue;
  23.                 long long ans = r/y;
  24.                 h.insert(ans);
  25.                 y*=b;
  26.             }
  27.             x*=a;
  28.  
  29.         }
  30.         long long total = h.size();
  31.         cout<<total<<endl;
  32.        
  33.     }
  34. }