wa了点4求调

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

lucy2012 @ 2024-08-30 15:22:02

#include<bits/stdc++.h>
using namespace std;
int x,y,prime[100010],ans=0,q; 
int f(int a,int b){
    if(b==0){
        if(a==x)
            return 1;
        else
            return 0;
    }
    return f(b,a%b);
}
int main(){   
    cin>>x>>y;
    q=y/x;
    for(int i=1;i*x<=y;i++){
        if(q%i==0&&f(q/i*x,i*x)){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

by lzh_juruo @ 2024-08-30 15:27:52

@lucy2012

加特判:

if(y%x!= 0){
    cout<<0;
    return 0;
}

by lucy2012 @ 2024-08-30 15:29:57

@lzh_juruo 谢谢你!!!感动~


by daoblekill @ 2024-09-05 20:03:35

666


by LTY9575 @ 2024-09-18 13:32:31

666


|