1 条题解
-
0HLBhahaqiu LV 8 MOD @ 2020-09-15 13:17:01
#include <cstdio>
using namespace std;int T;
int a[45000];bool huzhi(int a,int b)
{
int r=a%b;
while (r)
{
a=b;
b=r;
r=a%b;
}
return b==1;
}int main()
{
scanf("%d",&T);
for (int i=1;i<=T;i++)
{
int len=0;
int ans=0;
int a0,a1,b0,b1;
scanf("%d%d%d%d",&a0,&a1,&b0,&b1);
if (b1%a1) {printf("0\n");continue;}
int k1=a0/a1;
int k2=b1/b0;
int k3=b1/a1;
for (int j=1;j*j<=k3;j++)
if (k3%j==0) a[++len]=j;
for (int j=1;j<=len;j++)
{
if (huzhi(a[j],k1)&&huzhi(k3/a[j],k2)) ans++;
if (huzhi(k3/a[j],k1)&&huzhi(a[j],k2)) ans++;
}
if (a[len]==k3/a[len]&&huzhi(a[len],k1)&&huzhi(a[len],k2)) ans--;
printf("%d\n",ans);
}return 0;
}
- 1