题意:如题。
#include <iostream>
#include <vector>
using namespace std;
int dd(int x, int y);
void main()
{
vector<vector<int> > tmpbox;
unsigned int a;
unsigned int b;
while (cin >> a >> b)
{
if (a > 1000 || b > 1000)
continue;
vector<int> _tmp;
_tmp.push_back(a);
_tmp.push_back(b);
tmpbox.push_back(_tmp);
}
for (vector<vector<int> >::iterator it = tmpbox.begin(); it != tmpbox.end(); ++it)
{
int ntmp = dd((*it)[0], (*it)[1]);
cout << (*it)[0] / ntmp * (*it)[1] << endl;
}
}
int dd(int x, int y)
{
if(x < y)
{
x = x ^ y;
y = x ^ y;
x = x ^ y;
}
while(y != 0)
{
x = x % y;
x = x ^ y;
y = x ^ y;
x = x ^ y;
}
return x;
}
#include <iostream>
using namespace std;
long gcd(long m, long n)
{
while (n != 0)
{
long rem = m % n;
m= n;
n=rem;
}
return m;
}
#define change(m, n) m=m^n,n=m^n,m=m^n
void main()
{
long m, n;
while (cin >> m>> n){
if (n>m)change(m, n);
cout << m/gcd(m,n)*n<<endl;
}}