View Code of Problem 59

#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
  return (y==0?x:gcd(y,x%y));
}
int main()
{
  ll x,y;
  while(cin>>x>>y){
    ll tmp=gcd(x,y);
    cout<<x/tmp*y<<" "<<tmp<<endl;
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 59