TLE一个
我的code
#include<bits/stdc++.h>
//#define ?
#define endl "\n"
#define Fc ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define maxn 1005
using namespace std;
ll lcm(ll x, ll y) {
return x * y / __gcd(x, y);
}
ll t, a0, a1, b0, b1;
int main() {
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
scanf("%lld", &t);
while (t--) {
ll cnt = 0;
scanf("%lld%lld%lld%lld", &a0, &a1, &b0, &b1);
for (ll x = 1; x <= b1 / x; ++x) {
if (b1 % x == 0) {
if (__gcd(x, a0) == a1 && lcm(x, b0) == b1)
++cnt;
if (b1 / x != x)
if (__gcd(b1 / x, a0) == a1 && lcm(b1 / x, b0) == b1)
++cnt;
}
}
printf("%lld\n", cnt);
}
return 0;
}