P1072 Hankson 的趣味题

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll a0, a1, b0, b1;
int main() {
    cin >> n;
    while(n--) {
        cin >> a0 >> a1 >> b0 >> b1;
        ll ans = 0;
        for(ll i = 1; i * i <= b1; i++) {
            if(b1 % i)
                continue;
            if(i % a1 == 0 && i >= a1 && __gcd(b1 / b0, b1 / i) == 1 && __gcd(a0 / a1, i / a1) == 1)
                ans++;
            if((b1 / i) % a1 == 0 && (b1 / i) >= a1 && i * i != b1 && __gcd(b1 / b0, b1 / (b1 / i)) == 1 && __gcd(a0 / a1, (b1 / i) / a1) == 1)
                ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

 

上一篇:真Unity3d_Astarpath的应用


下一篇:1626:【例 2】Hankson 的趣味题