简单
2024-07-24 10:56:52
发布于:广东
6阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
int main()
{
int n;
cin >> n;
while (n-- > 0)
{
int a0, a1, b0, b1, ans = 0;
cin >> a0 >> a1 >> b0 >> b1;
int p = a0 / a1, q = b1 / b0;
for (int i = 1; i <= sqrt(b1); i++)
if (b1 % i == 0)
{
if ((i % a1 == 0) && (gcd(i / a1, p) == 1) && (gcd(q, b1 / i) == 1))
ans++;
int j = b1 / i;
if (i == j)
continue;
if ((j % a1 == 0) && (gcd(j / a1, p) == 1) && (gcd(q, b1 / j) == 1))
ans++;
}
cout << ans << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个