给出X,Y
X 代表 m,n 的最小公约数,Y代表m,n的最小公倍数
求出m,n:
ANS1:
#include<iostream>
using namespace std;
int main(){
int x,y;
cin >> x >> y;
int m,n;
// y = m*n/x;
//so m*n = x*y;
int num = 0;
for(int i = 1;i<y/x;i++){
m = x*i;
for(int j = 1;j<y/x;j++){
n = x*j;
if(m*n == x*y && n%m!=0 && m%n!=0){
num++;
cout << m << " " << n << endl;
}
}
}
cout << num << endl;
return 0;
return 0;
}
ANS2:
#include <iostream>
#include <cmath>
using namespace std;
int x,y,ans=0;
int gcd(int a, int b){
if(b==0) return a;
return gcd(b,a%b);
}
int main(){
cin>>x>>y;
int s=x*y;
for(int p=x;p<=sqrt(s);p+=x){
int q=s/p;
if(q<p) break;
if(gcd(q,p)==x&&p*q==s) ans++;
}
cout<<ans*2;
return 0;
}