90 求调

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

Lukas_gaoxi_yan @ 2024-08-12 07:44:15

#include<bits/stdc++.h>
using namespace std;
long long n,s,m,ans;
int main(){
    cin>>n>>m;
    s=n*m;
    for(long long i=1;i<=sqrt(s);i++){
        if(s%i==0&&i==(s/i)){
            ans=ans+1;
            continue;
        }
        if(s%i==0&&__gcd(i,s/i)==n){
            ans=ans+2;
        }
    }
    cout<<ans;
    return 0;
} 

by lovely_codecat @ 2024-08-12 07:53:39

@zhizhengaoxiyan

#include<bits/stdc++.h>
using namespace std;
long long n,s,m,ans;
int main(){
    cin>>n>>m;
    s=n*m;
    for(long long i=1;i<=sqrt(s);i++){
        if(s%i==0&&__gcd(i,s/i)==n){
            ans=ans+2;
        }
    }
    cout<<ans-(n==m);
    return 0;
} 

玄学掉精度导致的 @zhizhengaoxiyan


by __F__ @ 2024-08-12 07:59:24

@zhizhengaoxiyan 你在几楼


|