Go: package main

import "fmt"

func main() {
	for {
		var x, y int
		fmt.Scanf("%d %d", &x, &y)
		if x < y {
			rep := x
			x, y = y, rep
		}
		gcd := x % y
		lcm := x * y
		for gcd != 0 {
			x, y, gcd = y, gcd, x%y
		}
		fmt.Printf("%d %d\n", y, lcm/y)
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int a, b, c, d,r,s,h;
	for (cin >> a >> b){
		//c
		h = a;
		s = b; {
			r = h % s;
			if (r == 0) {
				c = s;
				break;
			}
			h = s;
			s = r;
		}

		//d
		h = a;
		s = b;
		if (a < b){
			for (;;){
				if ((b % a) == 0){
					d = b;
					break;
				}
				b = b + s;
			}
		}
		else if (a >= b){
			for (;;){
				if ((a % b) == 0){
					d = a;
					break;
				}
				a = a + h;
			}
		}

		cout << c << " " << d << endl;
	}
}

C++: /*
http://blog.csdn.net/liuke19950717
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	if(!b)
	{
		return a;
	}
	return gcd(b,a%b);
}
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		int tp=gcd(n,m);
		printf("%d %d\n",tp,n/tp*m);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int a,n;
  cin>>a>>n;
  cout<<gcd(a,n)<<" "<<lcm(a,n)<<endl;
  
}

C++: #include <iostream>
using namespace std;

long int Gcm(long int a,long int b){

    long int temp=0;
    long int r=1;
    //aとbの最大公約数を求める
    //a,b入力を行う（a>b）。a=b*q+rの形で計算していく
    //b%rの値が０になったときのbがa,bの最大公約数(cとする)となる
    //最小公倍数は、c*a'=a,c*b'=bを満たすa',b'とcとの積である
    if(a<b){
        temp = a;
        a = b;
        b = temp;
    }
    while(r!=0){
        r = a%b;
        a = b;
        b = r;//aが最大公約数
    }
    return a;
}

int main(){
    long int x,y;
    long int gcd,lcm;

    while(cin >> x >> y){

    gcd = Gcm(x,y);

    x = x/gcd;
    y = y/gcd;

    lcm = x * y * gcd;

    cout << gcd <<" "<< lcm << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 long long int a, b, c, temp, min, A, B;
 while(cin >> a >> b){
  if(a == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(b == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(a < b){
    temp = a;
    a = b;
    b = temp;
  }

    
  else if (a > b){
    A = a;
    B = b;

    while(1){
      c = A % B;
      if(c == 0) break;
      else if(c != 0){
        A = B;
        B = c;
      }
    }
    min = (a * b) / B;
    cout << B << " " << min << endl;
  }
  else if(a == b){
    cout << a << " " << a << endl;
  }

 }
 return 0; 
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll g,l;

ll gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

ll lcm(int a,int b){
	return a/g*b;
}

int main(){
	ll a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF){
		g=gcd(a,b);
		l=lcm(a,b);
		printf("%lld %lld\n",g,l);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define LL long long

LL gcd(LL a, LL b) {
	if (a < b)std::swap(a, b);
	if (a%b != 0)gcd(b, a%b);
	else return b;
}

int main() {
	LL A, B;
	while (std::cin >> A >> B) {
		LL g = gcd(A, B);
		std::cout << g << " " << (A*B) / g << std::endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, s, t;
	
	while(cin >> a >> b){
		for(int i = (a > b)? b : a; i >= 1; i--){
			if(b%i == 0 && a%i == 0){
				cout << i << " ";
				break;
			}
		}
		s = a;
		t = b;
		while(s != t){
			if(s > t){
				while(s > t){
					t += b;
				}
			} else {
				while(t > s){
					s += a;
				}
			}
		}
		cout << s << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;

int gcd(int x, int y)
{
    while(true){
        x=x%y;
        if(x==0) return y;
        y=y%x;
        if(y==0) return x;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    while(cin>>x>>y){
        int g=gcd(x, y);
        int l=x/g*y;
        cout<<g<<' '<<l<<'\n';
    }
    return 0;
}

C++: #include<iostream>
#include<utility>
using namespace std;
int main()
{
  long long int n=0,m=0;
  long long int i=0,j=0,l=0;

  while(scanf("%d %d",&n,&m) != EOF)
    {
      i = n;
      j = m;

      //koyaku
      if((n >= m) != true)swap(n,m);
      while(1)
	{
	  int amari = n % m;
	  n = m;
	  m = amari;
	  if(amari == 0) break;
	}
      
      //kobai
      l = i*j/n;
      
      cout << n << " " << l << endl;
    }
}

C++: #include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int a,b;

    while(scanf("%d%d",&a,&b)!=EOF){
        int gcd=a,tmp_b=b;
        int tmp;
        while(tmp_b!=0){
            tmp=gcd%tmp_b;
            gcd=tmp_b;
            tmp_b=tmp;
        }

        printf("%d %d\n",gcd,(int)((long)a*b/(long)gcd));
    }

    return 0;
}

C++: #include<stdio.h>

int max(int a, int b){
  return (a > b) ? a : b;
}

int min(int a, int b){
  return (a < b) ? a : b;
}

int calcGCD(int a, int b){
  int _min, _max, r;
  _max = max(a, b);
  _min = min(a, b);
  r = _max % _min;
  while(r != 0){
    _max = _min;
    _min = r;
    r = _max%_min;
  }
  return _min;
}

int calcLCM(int a, int b){
  int GCD, LCM;
  GCD = calcGCD(a, b);
  LCM = a * b / GCD;
  return LCM;
}
int main(){
  int a, b;
  int list[50][2];
  int j = 0;
  while(scanf("%d%d", &a, &b)!=EOF){
    list[j][0] = calcGCD(a, b);
    list[j][1] = calcLCM(a, b);
    j+=1;
  }
  int i;
  for(i=0; i<j; i++){
    printf("%d %d\n", list[i][0], list[i][1]);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int calcGcd(int x, int y)
{
    int r;

    if (x < y)
    {
        swap(x, y);
    }

    while(y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main( )
{
    int a, b;
    int gcd, lcm;
 
    while(cin >> a >>  b)
    {
        gcd = calcGcd(a, b);
        lcm = a / gcd * b;

        cout << gcd << " " << lcm << endl; 
    }

    return 0;
}

C++: #include<iostream>
#include<argolithm>

int gcd( unsigned int, unsigned int );
int main(void)
{
	unsigned int a, b, g, l;

	while( std::cin >> a >> b ){
		g = gcd( a, b );
		l = a * b / g;
		std::cout << g << std::endl;
		std::cout << l << std::endl;
	}

	return 0;
}

int gcd( unsigned int a, unsigned int b ){
	int n, i;
	unsigned int tmp[4];

	tmp[0] = std::max( a, b );
	tmp[1] = std::mix( a, b );

	for( n = 0;; n++ ){
		for( i = 1;(tmp[( n + 2 ) % 3 ] = tmp[ n % 3 ] - tmp[( n + 1 ) % 3 ] * i ) >= tmp[( n + 1 ) % 3]; i++ ){
			if( tmp[( n + 2 ) % 3 ] == 0 ){
				return tmp[( n + 1 ) % 3 ];
			}
		}
		if( n > 2000000000 ){
			return -1;
		}
	}

	return -1;
}

C++: #include<iostream>
using namespace std;

int main()
{
    unsigned long long a, b;

    while( cin >> a >> b )
    {

        if( a > b && a % b == 0 )       //値が大きい場合の最大公約数を先に求めておく
        {
            cout << b << " " << a << endl;
            break;
        }
        if( b <= a && b % a == 0 )
        {
             cout << a << " " << b << endl;
            break;
        }

        for( int i = a; i > 0; i-- ) 
        {
                if( a % i == 0 && b % i == 0 ) 
                {
                    cout << i << " " << a * b / i << endl;
                    break;
                }
        }
    }
    return 0;
}