显示代码纯文本
#include<cstdio>
#define syy myson
using namespace std;
typedef long long LL;
int n,i;
LL a0,a1,b0,b1,ans;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
LL lcm(int a,int b)
{
return LL(a)/LL(gcd(a,b))*LL(b);
}
void cal(int x)
{
if((gcd(x,a0)==a1)&&(lcm(x,b0)==b1))ans++;
}
int Main()
{
freopen("son.in","r",stdin);freopen("son.out","w",stdout);
scanf("%d",&n);
while(n--)
{
scanf("%I64d%I64d%I64d%I64d",&a0,&a1,&b0,&b1);
ans=0;
for(i=1;i*i<=b1;i++)if(b1%i==0)
{
cal(i);
if(i*i!=b1)cal(b1/i);
}
printf("%d\n",ans);
}
return 0;
}
int main(){;}
int syy=Main();