Go: package main

import "fmt"

func main() {
	var gcdArr, lcmArr [100]int
	var count int
	for {
		var x, y int
		fmt.Scanf("%d %d", &x, &y)
		if x == 0 {
			break
		}
		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
		}
		gcdArr[count] = y
		lcmArr[count] = lcm / y
		count++
	}
	for i := 0; i < count; i++ {
		fmt.Printf("%d %d\n", gcdArr[i], lcmArr[i])
	}
}

C++: 













































File Edit Options Buffers Tools C++ Help
const int MAX = (int)1e5 + 5;

template<typename T>
T gcd(T a, T b)
{
        T c;
        while (a != 0) {
                c = a; a = b%a;  b = c;
        }
        return b;
}

template<typename T>
T lcm(T m, T n)
{
        return ((m / gcd(m, n)) * n);
}

signed main() {
  ll a, b;
  while(cin >> a >> b) {
    cout << gcd(a,b) << " " << lcm(a,b) << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int gcd(int a, int b){
	if((0 == a) || ( 0 == b)) return 0;
	
	while( a != b){
		if( a > b) a = a - b;
		else       b = b - a;
	}
	return a;
}

int lcm(int a, int b){
	if((0 == a) || ( 0 == b)) return 0;
	
	return ((a / gcd(a,b)) * b);
}

int main(){
	int a, b;
	
	while(cin >> a >> b){
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
		
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a, b, s, t, c;
	while(cin >> a >> b){
		s = a;
		t = b;
		c = 1;
		for(int tmp = (a > b)? b : a, i = 2; i <= tmp; i++){
			while(s%i == 0 && t%i == 0){
				s /= i;
				t /= i;
				tmp /= i;
				c *= i;
			}
		}
		cout << c << " " << (a/c*b) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
#define ep 0.00001

int main()
{
	int a, b, temp;
	int a0, b0;
	int a1, b1;
	int gcd, lcm;
	
	while (cin >> a >> b) {
		if (a > b) {
			temp = a;
			a = b;
			b = temp;
		}
		a0 = a;
		b0 = b;
		while (a0) {
			temp = b0 % a0;
			b0 = a0;
			a0 = temp;
		}
		gcd = b0;
		a1 = a;
		b1 = b;
		while (a1 != b1) {
			if (a1 < b1)
				a1 += a;
			else if (a1 > b1)
				b1 += b;
		}
		lcm = a1;
		cout << gcd << " " << lcm << "\n";
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
int a,b,i;
while(cin>>a>>b){
int max=0,min;
i=a;
while(max=0){
if(a%i==0 && b%i==0){
max=i;}
i--;}
min=(a/max)*b;
cout<<max<<" "<<min<<endl;
}
return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

int gcd(int a,int b)//O(log max(a,b)) 
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main()
{
    int a,b, g;
    while(cin >> a >> b)
    {
        g = gcd(a,b);
        cout << g << " " << (a / g) * b << endl;
        
    }
    return 0;

}

C++: #include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

#define MOD 1000000007
using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int main(){
  ll a,b;
  while(cin >> a >> b){
    cout << __gcd(a,b) << ' ' << a / __gcd(a,b) * b << endl;
  }
  
}

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

using namespace std;

typedef long long int llongi;

int GCD(const int& a, const int& b) {
	if (b == 0) {
		return a;
	}
	GCD(b, a%b);
}

int main() {
	int a, b;
	int gcd;
	while (cin >> a >> b) {
		a = max(a, b);
		b = min(a, b);
		gcd = GCD(a, b);
		cout << gcd << " " << a * b / gcd << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>

int main()
{
  log long int num1,num2,num;
  while(scanf("%lld %lld",num1,&num2)!=EOF){
  num=num1*num2;
  while(num1 !=num2)
  if(num1>num2)
  num1=num1-num2;
  else
  num2=num2-num1;
  }
  printf("%lld %dll\n",num1,num/num1);
  return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  long long a, b, c, d, GCD, LCM;
  while(cin >> a >> b) {
    c = a;
    d = b;
    if((a==0) && (b==0)) cout << a << " ";
    else {
      while(a!=b) {
	if(a>b) a=a-b;
	else b=b-a;
      } 
      GCD = a;  
      cout << GCD << " ";
    }  
    c/=GCD;  
    LCM = c*d;   
    cout << LCM << endl; 
  } 
  return 0;
}

C++: #include <iostream>
using namespace std;
double gcd(int,int); //最大公約数
double lcm(int,int); //最小公倍数
int main(){
    int a,b;
    while (cin >>a >>b){
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
}

double gcd(int a,int b){
    int n;
    if (a>b){
        n=b;
        b=a;
        a=n;
    }
    n = a;
    while(b%a!=0){
        n=b%a;
        b=a;
        a=n;
    }
    return n;
}

double lcm(int a,int b){
    double n = a/gcd(a,b)*b;
    return n;
}

C++: #include<cstdio>

int gcd(int a, int b){
    if(a == b)
        return a;
    else if(a > b)
        a -= b;
    else if(a < b)
        b -= a;
    return gcd(a, b);
}

int lcm(int a, int b){

    return (a / gcd(a, b)) * (b / gcd(a, b)) * gcd(a, b);
}

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

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#define MAX 50000
using namespace std;

int p[MAX];

int main()
{
	//素数
	fill(p, p + MAX, 1);
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				p[i] = 0;
				break;
			}
		}
	}

	int a, b;
	while (cin >> a >> b){
		int gcm = 1;
		bool flag = true;
		while (flag){
			for (int i = 2;; i++){
				if (p[i] == 1 && a % i == 0 && b % i == 0){
					gcm = gcm * i;
					a = a / i;
					b = b / i;
					break;
				}
				if (i == min(a, b)){
					flag = false;
					break;
				}
			}
		}
		int lcm = gcm * a * b;
		cout << gcm << " " << lcm << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int a, b, m, n, tmp;
	while(cin >> a >> b) {
		if(a > b) {
			m = a;
			n = b;
		} else {
			m = b;
			n = a;
		}
		while(n != 0) {
			tmp = n;
			n = m % n;
			m = tmp;
		}
		tmp = a * b / m;
		cout << m << " " << tmp << 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){
				break;
			}
		}
		s = a;
		t = b;
		while(s != t){
			if(s > t){
				while(s > t){
					t += b;
				}
			} else {
				while(t > s){
					s += a;
				}
			}
		}
		cout << i << " " << s << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a,b,i,ii,iii,maxkouyakusuu=0,lowkoubaisuu=2000000000;
while(i>50){
cin>>a>>b;
for(ii=0;ii<a*b;++ii){
  if(a%ii==0 && b%ii==0 && ii>maxkouyakusuu){
    maxkouyakusuu=ii;
  }
for(iii=0;iii<a*b;++iii){
  if(iii%a==0 && iii%b==0 && iii<lowkoubaisuu){
    lowkoubaisuu=iii;
  }
}
}
  cout<<maxkouyakusuu<<" "<<lowkoubaisuu<<endl;
  ++i;
}
  return 0;
}

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

int main() {
	int a, b,i;
		while (cin >> a >> b) {
			for (i = a; i > 0; i--) {
				if (b%i == 0 && a%i == 0) {
					cout << i << " ";
					break;
				}
				if (i == 0)
					cout << 1 << " ";
			}
			if (a > b)
				i = a;
			else
				i = b;
			while (i%b != 0) {
				i += a;
			}

			if (a > b) {
				for (i = a; i%b; i += a);
				cout << i << endl;
			}
			else {
				for (i = b; i%a; i += b);
				cout << i << endl;
			}
		}
	return 0;
}

C++: #include <stdio.h>

int gcd( int m, int n)
{
if(n==0)
return m;
else
return gcd(n,m%n);
}

int lcm( int x, int y)
{
return( x * y / gcd (x , y));
}

int main()
{
int a, b;
while(scanf("%d%d", &a,&b)==2)
{
printf("%d", gcd( a, b));
printf(" %d", lcm(a , b));
}
return 0;
}