90分,求调

P1029 [NOIP2001 普及组] 最大公约数和最小公倍数问题

clever_person @ 2024-10-08 21:06:32

90 Code

#include <bits/stdc++.h>
using namespace std;

int main () {
    int x, y; cin >> x >> y;
    long long z = 1ll * x * y, ans = 0, k = y / x;
    for (int i = 1; i <= k; ++i) {
        if (k % i != 0) continue;
        long long gcd = __gcd(1ll * i, k / i);
        if (gcd != 1) continue;
        ans++;
    }
    cout << ans << endl;

}

by pi3_141592653589 @ 2024-10-09 21:40:39

特判y不为x的倍数的情况。


by pi3_141592653589 @ 2024-10-09 21:40:58

@clever_person


|