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



Sample input:
8 6
50000000 30000000


Sample output:
2 24
10000000 150000000

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/gcd(a,b)
        print g, l

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/gcd(a,b)
        print g, l
    except:
        break

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/g
        print g, l
    except:
        break

Submission status: Runtime Error

Solution code:
while True:
  a,b = map(int, raw_input().split())
  GCD = a if a > b else b
  LCM = a * b
  tmp = GCD
  #GCD 最大公約数
  #LCM 最小公倍数
  for i in range(tmp, 0, -1):
    if a % i == 0 and b % i == 0: GCD = i
  tmp = LCM
  for i in range(tmp, 0, -1):
    if i % a == 0 and i % i == 0: LCM = i
  print str(GCD) + " " + str(LCM)

Submission status: Runtime Error

Solution code:
while True:
  a,b = map(int, raw_input().split())
  GCD = a if a > b else b
  LCM = a * b
  tmp = GCD
  for i in range(tmp, 0, -1):
    if a % i == 0 and b % i == 0: GCD = i
  tmp = LCM
  for i in range(tmp, 0, -1):
    if i % a == 0 and i % i == 0: LCM = i
  print str(GCD) + " " + str(LCM)

Submission status: Runtime Error

Solution code:
while True:
  try:
    a,b = map(int, raw_input().split())
    GCD = a if a > b else b
    LCM = a * b
    tmp = GCD
    for i in range(tmp, 0, -1):
      if a % i == 0 and b % i == 0: GCD = i
    tmp = LCM
    for i in range(tmp, 0, -1):
      if i % a == 0 and i % i == 0: LCM = i
    print str(GCD) + " " + str(LCM)
  except EOFError:
    break

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    while a%b:
        a,b=b,a%b
    return b

def lcm(a,b):
    return a*b/gcd(a,b)

while 1:
    a,b=map(int, raw_input().split())
print gcd(a,b),lcm(a,b)

Submission status: Runtime Error

Solution code:

def gcd(a,b):
    while a%b:
        a,b=b,a%b
    return b

def lcm(a,b):
    return a*b/gcd(a,b)

while 1:
    a,b=map(int, raw_input().split())
    a,b=max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Submission status: Runtime Error

Solution code:
def readint():
    for line in sys.stdin:
        yield map(int,line.split())

def gcd(x,y):
    [x,y] = [max(x,y),min(x,y)]
    z = x % y
    while z > 0:
        [x,y,z] = [y,z,x % y]
    return y

for [x,y] in readint():
    GCD = gcd(x,y)
    mx = x/GCD
    print GCD,mx*y

Submission status: Runtime Error

Solution code:
i=a
j=a
while i>0:
           if b%i==0 and a%i==0:
                  print i 
 	          break
	   else:
		  i=i-1
while j>0:
	　 if j%b==0 and j%a==0:
                  print j
                  break
           else:

		  j=j+1

Submission status: WA: Presentation Error

Solution code:

import sys
from fractions import gcd
[print("{}{}".format(gcd(k[0], k[1]), k[0] * k[1] // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]

Submission status: WA: Presentation Error

Solution code:

import sys
from fractions import gcd
[print("{}{}".format(gcd(k[0], k[1]), (k[0] * k[1]) // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]

Submission status: WA: Presentation Error

Solution code:
import sys

def gcd(m, n):
    if n != 0:
        return gcd(n, m % n)
    else:
        return m

for line in sys.stdin.readlines():
    m, n = map(int, line.split())
    g = gcd(m, n)
    l = m * n // g    # LCM
    print(g, ' ', l)

Submission status: WA: Presentation Error

Solution code:
from sys import stdin
import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return a*b/gcd

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = math.floor(LCM(a,b))

    print(str(gcd)+" "+str(lcm))
    print()

Submission status: WA: Presentation Error

Solution code:
from sys import stdin
import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return int(a*b/gcd)

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = LCM(a,b)

    print(str(gcd)+" "+str(lcm))
    print()