https://ac.nowcoder.com/acm/contest/57359/D
暴力搜索b即可
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll gcd(ll a,ll b)
{
if(a==0)
{
return b;
}
if(b==0)
{
return a;
}
if(a>b)
{
return gcd(a%b,b);
}
else
return gcd(a,b%a);
}
int main(){
ios::sync_with_stdio(false);
cin>>t;
//cout<<gcd(9,0)<<endl;
while(t--)
{
ll k, c,n;
ll ans=0;
cin>>k>>c>>n;
for(int i=1;i*i<=c;i++)
{
ll x1,b1,a1;
if(c%i)continue;
x1=i;
b1=c/i;
a1=(b1*(x1-1))/k;
if((b1*(x1-1))%k)continue;
if(a1==0||b1==0)continue;
if(gcd(a1,b1)>=n)ans++;
}
for(int i=1;i*i<=c;i++)
{
ll x1,b1,a1;
if(c%i)continue;
b1=i;
x1=c/i;
a1=(b1*(x1-1))/k;
if((b1*(x1-1))%k)continue;
if(a1==0||b1==0)continue;
if(gcd(a1,b1)>=n)ans++;
}
cout<<ans<<endl;
}
return 0;
}