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: Time Limit Exceeded)

#include<stdio.h>

long kyk(long num[2]);
long kbi(long num[2]);

long kbi(long num[2])
{
	long i;
	
	for(i = num[1] ; i >= 1 ; i--)
	{
		if(0 == num[0] % i && 0 == num[1] % i)
		{
			return i;
		}
	}
}

long kyk(long num[2])
{
	long yak[4],yaak,i;
		
		
		
		yak[0] = num[1];
		yak[1] = num[0] - num[1];
		
		while(1)
		{
			yak[2] = yak[0] - yak[1];
			
			if(yak[1]<yak[2])
			{
				yak[3] = yak[1];
				
				for(i=2;;i++)
				{
					yak[1] = yak[3] * i;
					
					if(yak[1] >= yak[2])
					{
						break;
					}
				}
				
				yak[2] = yak[0] - yak[1];
			}
			if(yak[1]!=yak[2])
			{
				yak[0] = num[1];
				yak[1] = num[0] - num[1];
			}
			
			else
			{
				return yak[1];
			}
		}
		
}

int main(void)
{
	long  i,kobai,num[2],koyak,escape;
	
	while(scanf("%d %d",&num[0],&num[1]) != EOF )
	{
		kobai = 0;
		koyak = 0;
		
		if(num[0] < num[1])
		{
			escape = num[0];
			num[0] = num[1];
			num[1] = escape;
		}
		
		koyak = kyk(num);
		
		kobai = kbi(num);
		
		printf("%ld %ld\n",koyak,kobai);
		
	}
	
	return 0;
}