#include <bits/stdc++.h>
using namespace std;
int gys(int a,int b){
int t;
while ((t=a%b)!=0)//辗转相除法效率高
{
a=b;
b=t;
}
return b;//a%b=0时返回b为最大公约数
}
int main(){
int m,n,s;
cin>>m>>n;
s=gys(m,n);
cout<<s<<endl;
int t;
t=m*n/s;
cout<<t<<endl;
return 0;
}
求最大公约数以及最小公倍数
于 2022-03-25 08:28:04 首次发布