90pts

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

zyc0611 @ 2024-08-05 20:30:40

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

long long gcd(long long a,long long b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(){
    int cnt=0;
    long long a,b;
    cin>>a>>b;
    long long t = a*b;
    for(long long i=1;i*i<=t;i++){
        if(t%i==0){
            if(gcd(i,t/i)==a){
                cnt+=2;
            }
        }

    }
    cout<<cnt;

    return 0;
}

by _he_he_ @ 2024-08-06 11:22:03

要特判兄弟


by _he_he_ @ 2024-08-07 11:30:48

当a==b的时候,cnt要先减一


by zyc0611 @ 2024-08-07 12:00:26

@LIFE_RS A了,谢谢


|