Problem:
GCD and LCM

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Constraints

0 < a, b ≤ 2,000,000,000

LCM(a, b) ≤ 2,000,000,000

The number of data sets ≤ 50

Output

For each data set, print GCD and LCM separated by a single space in a line.

Sample Input

8 6
50000000 30000000

Output for the Sample Input

2 24
10000000 150000000

Solution in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;

namespace AOJ.Volume0
{
    class Program0005
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int[]> queue = new Queue<int[]>();

            while ((input = Console.ReadLine()) != null)
            {
                string[] splitedInput = input.Split(' ');
                int[] param = new int[2];

                for (int i = 0; i < 2; i++)
                {
                    param[i] = int.Parse(splitedInput[i]);
                }

                int maxKoyaku, minKobai;
                maxKoyaku = GetMaxKoyaku(param[0], param[1]);
                minKobai = GetMinKobai(param[0], param[1], maxKoyaku);

                queue.Enqueue(new[] { maxKoyaku, minKobai });
            }

            foreach (var ans in queue)
            {
                Console.WriteLine("{0} {1}", ans[0], ans[1]);
            }
        }

        static int GetMaxKoyaku(int x, int y)
        {
            int minXY = Math.Min(x, y);
            int maxXY = Math.Max(x, y);

            for (int i = 1; i <= minXY; i++)
            {
                if (minXY % i == 0)
                {
                    int temp = minXY / i;
                    if (maxXY % temp == 0)
                    {
                        return temp;
                    }
                }
            }

            return 1;
        }

        static int GetMinKobai(int x, int y, int maxKoyaku)
        {
            long kobai = Math.BigMul(x, y);
            return (int)(kobai / maxKoyaku);
        }
    }
}