Topic link
Title:
Gives you c, d, xc,d,xc,d,x is in accordance withc ∗ lcm (a, b) − d ∗ gcd (a, b) = xc*lcm(a,b)-d*gcd(a,b)=xc∗lcm(a,b)−d∗gcd(a,b)=x 's(a, b) (a, b)(a,b ) How many kinds are there?
Ideas:
First, according to c ∗ lcm (a, b) − d ∗ gcd (a, b) = xc*lcm(a,b)-d*gcd(a,b)=xc∗lcm(a,b)−d∗gcd(a,b)=x Pei Shu theorem gives:
x 是 g c d ( l c m ( a , b ) , g c d ( a , b ) ) . x是gcd( lcm(a,b),gcd(a,b) ). x is g c d ( l c m ( a ,b),gcd(a,b)).
And gcd (lcm (a, b), gcd (a, b)) is equal to gcd (a, b). And gcd (lcm(a,b), gcd(a,b)) is equal to gcd(a,b). And g c d ( l c m ( a ,b),gcd(a,B ) ) and the like in G C D ( A ,b).
So gcd(a,b) is the factor of x. So we can enumerate the factors of x.
lcm=(x+d*gcd)/c
Look at lcm/gcd again. We can know that it is the product of the prime factors of a and b, so the prime factors can only be all in a or all in b, because we must be in addition to gcd(a,b).
Then we assume that lcm/gcd has a total of n prime factors. Then we have 2 n construction methods.
Then we need to sieve out the number of prime factors in 2e7. (Using a similar sieve)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include <immintrin.h>
#pragma GCC optimize(2)
#include <set>
#include <map>
#include <queue>
#include <string>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll, ll> pii;
#define mem(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << ": " << x << endl;
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<=(b);++i)
#define repr(i,b,a) for(int i=int(b);i>=(a);--i)
const int maxn = 2e7 + 10;
#define inf 0x3f3f3f3f
#define sf scanf
#define pf printf
const int mod = 998244353;
const int MOD = 10007;
int prime[maxn];
ll ans;
#define read read()
void init()
{
for(int i = 2; i < maxn; i++)
{
if(!prime[i])
{
for(int j = i; j < maxn; j += i)
{
prime[j]++;
}
}
}
}
void add(ll gcd,ll x,ll d,ll c)
{
ll lcm=x+d*gcd;
if(lcm%c==0)
{
lcm/=c;
if(lcm%gcd==0)
ans+=1LL<<prime[lcm/gcd];
}
}
void solve()
{
ll d,c,x;
ans=0;
scanf("%lld%lld%lld",&c,&d,&x);
for(int i=1;i<=sqrt(x);i++){
if(x%i==0){
add(i,x,d,c);
if(i*i!=x){
add(x/i,x,d,c);
}
}
}
printf("%lld\n",ans);
}
int main()
{
init();
ll t;
scanf("%lld",&t);
while(t--)
{
solve();
}
return 0;
}