求最大公约数顺便求最小公倍数
#include<bits/stdc++.h>
using namespace std;
int divi(int x,int y)
{
int z = y;
while( x%y != 0)
{
z = x % y;
x = y;
y = z;
}
return z;
}
int sub(int x,int y)
{
while( x != y )
{
if( x > y )
{
x = x - y;
}
else
{
y = y - x;
}
}
return x;
}
int vio(int x, int y)
{
int temp;
for(temp = x; ; temp--)
{
if( (x % temp == 0) && (y % temp == 0) )
break;
}
return temp;
}
int main()
{
int x,y;
cin >> x;
cin >> y;
int num1,num2;
num1 = divi(x,y);
num2 = sub(x,y);
int res = x*y/num1;
cout << num1 << endl;
cout << num2 << endl;
cout << res << endl;
}