比赛 板子大赛 评测结果 AAAAAATAAT
题目名称 最大公约数和最小公倍数问题 最终得分 80
用户昵称 秋_Water 运行时间 4.114 s
代码语言 C++ 内存使用 3.26 MiB
提交时间 2025-01-22 14:01:29
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
long long x,y,cnt,a[1000008],b[1000008],ans;
int main(){
    freopen("gcdpro.in","r",stdin);
    freopen("gcdpro.out","w",stdout);    
    cin>>x>>y;
    for(long long i=1;i<=x*y;i++){
        if((x*y)%i==0){
            a[++cnt]=i;
            b[cnt]=(x*y)/i;
        }
    }
    for(long long i=1;i<=cnt;i++){
        if(__gcd(a[i],b[i])==x||__gcd(a[i],b[i])==y){
            ans++;
        }
    }
    cout<<ans;
    
    return 0;
}