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: Accepted

Solution code:
# -*- coding:utf-8 -*-

def gcd(a,b):
    big,small=max(a,b),min(a,b)
    while big%small!=0:
        big,small=small,big%small
    return small

def lcm(a,b):
    return int(a*b/gcd(a,b))
 
def main():
    while True:
        try:
            IN=input()
            val=IN.split()
            g=gcd(int(val[0]),int(val[1]))
            l=lcm(int(val[0]),int(val[1]))

            print(g,l)
        except:
            break
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

while True:
    try:
	a,b = map(int,raw_input().split())
	tempa = a
	tempb = b
	while tempa % tempb != 0 :
	    tempa , tempb = (tempb,tempa%tempb)
	gcd = tempb
	lcm = a * b / gcd
	print "%d %d" % ( gcd, lcm)
	

    except EOFError:
	break

Submission status: Accepted

Solution code:
import sys
def kouyakusuu(a,b):
  A = max(a,b)
  B = min(a,b)
  d = A % B
  if d == 0:
    return B
  else:
    return kouyakusuu(B,d)
for line in sys.stdin.readlines():
  a,b = map(int,line.split())
  m = kouyakusuu(a,b)
  n = a*b//m
  print(m,n)

Submission status: Accepted

Solution code:
def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a%b)
while True:
	try:
		a, b = map(int, raw_input().strip().split(' '))
		print "%d %d" % (gcd(a, b), a*b/gcd(a, b))
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
    if a==b:
        return a
    while(b>0):
        a,b = b,a%b
        if b==0:
            return a
def lcm(a,b):
    n=1
    m=1
    while(n*a!=m*b):
        if n*a>m*b:
            m+=1
        elif n*a<m*b:
            n+=1
    return n*a
lines = sys.stdin.readlines()
for line in lines:
    line = line.split(" ")
    inp = []
    for i in line:
        inp.append(int(i))
    inp.sort()
    a = inp[0]
    b = inp[1]
    print("%d %d" % (gcd(a,b),lcm(a,b)))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

def gcd(a, b):
    m = a % b
    if m == 0:
        return b
    return gcd(b, m)

for l in sys.stdin:
  x, y = map(int, l.split())
  g = gcd(x, y)
  l = x * y / g
  print g, l

Submission status: Accepted

Solution code:
import sys
list = sys.stdin.readlines()

e=0
GCD = 0
def Euclide(a, b):
    if b == 0:
        return a
    if a < b:
        tmp = a
        a = b
        b = tmp
    e = a%b
    return Euclide(b, e)

for i in list:
    i = i.split(' ')
    GCD = Euclide(int(i[0]), int(i[1]))
    print(str(GCD)+" "+str(int(int(i[0])/GCD*int(i[1]))))

Submission status: Accepted

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

def lcm(a, b,gcdnum=0):
    if gcdnum==0:
        return a * b // gcd (a, b)
    else:
        return a * b // gcdnum

for line in sys.stdin:
    a,b = map(int,line.split())
    gcdnum = gcd(a,b)
    print "%d %d"%(gcdnum,lcm(a,b,gcdnum))

Submission status: Accepted

Solution code:
import sys

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

for line in sys.stdin:
    a, b= map(int, line.split())
    if a < b:
        a, b = b, a
    g = gcd(a,b)
    print g, a*b/g

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
    if b== 0:return a
    return gcd(b,a%b)
def return_lcm(a,b):
    prime = gcd(a,b)
    return prime*(a/prime)*(b/prime)
def solve():
    a = []
    for line in sys.stdin:
        digit_list = line.split(' ')
        new_list = []
        for j in digit_list:
            new_list.append(int(j))
        a.append(new_list)
    for data in a:
        print str(gcd(data[0],data[1])) + ' ' + str(return_lcm(data[0],data[1]))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

while True:
  try:
    a, b = map(int, raw_input().split())
  except EOFError:
    break
  print "%d %d" % (gcd(a, b), lcm(a, b))

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

import sys

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

for line in sys.stdin:
    a, b = map(int, line.split())
    print( str(gcd(a,b))+" "+str(lcm(a,b)) )

Submission status: Accepted

Solution code:
import sys

ary=[]
ans=[]
def gcd(a,b):
    x=sorted([a,b])
    while x[1]%x[0]!=0:
        dif=x[1]%x[0]
        x[1]=x[0]
        x[0]=dif
    return x[0]
for i in sys.stdin:
    ary.append(list(map(int,i.split())))
    ans.append([gcd(*ary[-1]),int(ary[-1][0]*ary[-1][1]/gcd(*ary[-1]))])
for i in range(len(ans)):
    print('{0:d} {1:d}'.format(*ans[i]))

Submission status: Accepted

Solution code:
while True:
    try:
        [x, y] = map(int, raw_input().split())
        if x < y:
            a = y
            b = x
        else:
            a = x
            b = y
        while a % b:
            c = a % b
            a = b
            b = c
        print "%d %d" % (b, x*y/b)
    except (EOFError):
        break

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(b % a, a)

try:
    while 1:
        a,b = list(map(int,input().split()))
        c = gcd(a, b)
        print('{} {}'.format(c,int(c * (a/c) * (b/c))))

except Exception:
    pass

Submission status: Accepted

Solution code:
def gcd(a,b):
	a,b=max(a,b),min(a,b)	
	while b!=0:
		a,b=b,a%b
	return a

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


while True:
	try:
		x,y=map(int,input().split())
		print(gcd(x,y),lcm(x,y))

	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys
for i in sys.stdin:
    m, n = map(int, i.split())
    t1, t2 = m, n
    while True:
        if m % n == 0:
            break
        m, n = n, m % n
    a = n
    b = (t1/ a) * t2
    print("{} {}".format(a, b))

Submission status: Accepted

Solution code:
while(True):
    try:
        (a, b) = map(int, input().split(" "))
        (x, y) = (a, b)
        while (x != 0):
            (x, y) = (y%x, x)
        print("%s %s" %(y, a*b//y))
    except:
        break

Submission status: Accepted

Solution code:
#coding:utf-8

while True:
    try:
        a, b = map(int, raw_input(). split())
        x = a * b
        while True:
            c = a % b
            a = b
            b = c
            if b == 0:
                break
        x = x / a
        print("%d %d" % (a, x))
    except:
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    t1, t2 = a, b
    while True:
        if a%b:
            a, b = b, a%b
        else:
            break
    gcd = b
    lcm = t1/gcd*t2
    print "%d %d" %(gcd, lcm)

Submission status: Accepted

Solution code:
import sys

def gcd(inta, intb):
    large = max(inta, intb)
    small = min(inta,intb)
    mod = large % small
    if mod ==0:
        return small
    else:
        return gcd(small, mod) 
    
def lcm(inta, intb, intgcd):
    return (inta * intb // intgcd)

sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = gcd(a, b)
    print(c, lcm(a, b, c))

Submission status: Accepted

Solution code:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
def lcm(a,b,g):
    return a*b/g

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

Submission status: Accepted

Solution code:
import sys
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
	return a*b//gcd(a,b)
	
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    print(gcd(a,b), lcm(a, b))

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield "".join(input())
        
        except EOFError:
            break
            
def calcGCD(a,b):#?????§??¬?´???°????±?????????????????????????????????????????????¨?????????
    if a>b:
        large = a
        small = b
    elif a<b:
        large = b
        small = a
    else:
        return a
        
    
    while True:
        
        if large == small:
            return large
        
        temp_small = large - small
        
        if temp_small < small:
            large = small
            small = temp_small 
        else:
            large = temp_small
            small = small

def calcLCM(a,b,gcd):#????°???¬?????°????±??????????
    lcm = a*b/gcd
    
    return lcm
    


if __name__  == "__main__":
    array = list(get_input())
    for i in range(len(array)):
    
        temp_a,temp_b = array[i].split()
    
        a,b = int(temp_a),int(temp_b)
    
        gcd = calcGCD(a,b)
        lcm = calcLCM(a,b,gcd)
        lcm = int(lcm)
        
        print("{} {}".format(gcd,lcm))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
	while True:		
		try:
			a, b = [int(x) for x in input().split(" ")]
		except:
			return
		else:
			print(gcd(a, b),lcm(a, b))
def lcm(a, b):
	return (a * b) // gcd(a,b)
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a	
			
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
dataset = sys.stdin.readlines()


def gcd(a, b):
    if b > a: return gcd(b, a)
    if a % b == 0: return b
    return gcd(b, a % b)

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

for item in dataset:
    a, b = list(map(int, item.split()))
    print(gcd(a, b), lcd(a,b))

Submission status: Accepted

Solution code:
import sys

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

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

for s in sys.stdin:
    a, b = map(int, s.split())
    print "%d %d"%(gcd(a, b), lcm(a, b))

Submission status: Accepted

Solution code:
import sys
def gcd(a,b):
    if a<b:
        t = a
        a = b
        b = t
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a

for i in sys.stdin:
    a,b = map(int, i.split())
    g = gcd(a,b)
    print(g, a*b//g)

Submission status: Accepted

Solution code:
ans=[]
while True:
	try:
		k,l=list(map(int,input().split(" ")))
		init_k=k
		init_l=l
#
		while True:
			if k%l==0:
				gcd=l
				tmp_1=init_k/gcd
				tmp_2=init_l/gcd
				lcm=gcd*tmp_1*tmp_2
				break
			else:
				tmp=k%l
				k=l
				l=tmp
		gcd=int(gcd)
		lcm=int(lcm)
		ans.append(str(gcd)+" "+str(lcm))
	except:
		break

for i in ans:
	print(i)

Submission status: Accepted

Solution code:
while True:
    try:
        (a, b) = map(int, input().split(" "))
        (x, y) = (a, b)
        while (x != 0):
            (x, y) = (y%x, x)
        print("%s %s" %(y, a*b//y))
    except:
        break

Submission status: Accepted

Solution code:
def gcd(a, b):
	if b == 0: return a
	else: return gcd(b, a % b)

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

while True:
	try:
		a, b = map(int, input().split())
		print(int(gcd(a, b)), int(lcm(a, b)))
	except EOFError:
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a,b):
    while b != 0:
        a , b = b , a % b
    return a
def lcm(a,b):
    return int(abs(a*b) / gcd(a,b))

while True:
    try:
        a, b = [int(x) for x in input().split()]
    except:
        exit()
    print(gcd(a,b),lcm(a,b))

Submission status: Accepted

Solution code:
def GcdLcm(a, b):
	p = a * b
	if a < b:
		a, b = b, a
	r = a % b
	while r != 0:
		a = b
		b = r
		r = a % b
	return [b, int(p / b)]

while True:
	try:
		a, b = [eval(item) for item in input().split()]
		g, l = GcdLcm(a, b)
		print(str(g), str(l))
	except EOFError:
		break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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


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


def main():
    for i in sys.stdin.readlines():
        a, b = [int(x) for x in i.split()]
        print(gcd(a, b), lcm(a, b))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
    a = list(map(int, s.split()))
    b = a[0]
    c = a[1]

    while c != 0:
        b, c = c, b%c

    d = a[0] * a[1] / b
    print(int(b), int(d))

Submission status: Accepted

Solution code:
import sys

def get_gcd(a, b):
    if a < b:
        a, b = b, a

    if a % b == 0:
        return b
    else:
        return get_gcd(b, a % b)

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

def main():
    while True:
        data = sys.stdin.readline().strip()
        if data is None or data == '':
            break

        nums = data.split(' ')
        a = int(nums[0])
        b = int(nums[1])
        gcd = get_gcd(a, b)
        lcm = get_lcm(a, b, gcd)
        print(gcd, lcm)
        
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math

a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num1=int(inl[0])
    check=1
    list=[]
    while check<=math.sqrt(num1):
        if num1%check==0:
            list.append(check)
            list.append(num1/check)
        check+=1
    list.sort()
    list.reverse()
    num2=int(inl[1])
    for i in list:
        if num2%i==0:
            gud=i
            break
    lcm=num1*num2/gud
    print gud,lcm

Submission status: Accepted

Solution code:
import sys

temp = []
largest = 1

for line in sys.stdin:
    a,b = [int(x) for x in line.split()]
    if a > b:
        x,y = a,b
    else:
        x,y = b,a
    while y:
        x,y = y,x%y
    smallest = x * (a/x) * (b/x)
    print('%d %d' % (x, smallest))

Submission status: Accepted

Solution code:
def gcd(x, y):
  if x < y:
    tmp = x
    x = y
    y = tmp
  while True:
    if y == 0:
      break
    x = x % y
    tmp = x
    x = y
    y = tmp

  return x

def lcm(x, y):
  return x * y / gcd(x, y)

while True:
  try:
    a, b = map(int, input().split())
    print(gcd(a, b), int(lcm(a, b)))
  except EOFError:
    break

Submission status: Accepted

Solution code:
while True:
    try:
        a,b = map(int, raw_input().split())
        x,y = (a,b) if a > b else (b,a)
        
        while x%y:
            m = x % y
            x,y = y,m

        print "%d %d" % (y, a*b/y)
    except (EOFError):
        break

Submission status: Accepted

Solution code:
import sys
for l in sys.stdin:
  a,b = map(int, l.split())
  x,y = (a,b) if a > b else (b,a)
  while x%y:
    m = x % y
    x,y = y,m
  print "%d %d" % (y, a*b/y)

Submission status: Accepted

Solution code:
import sys
for l in sys.stdin:
 x,y=map(int, l.split())
 m=x*y
 while x%y:x,y=y,x%y
 print "%d %d"%(y,m/y)

Submission status: Accepted

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

while True:
 try:
  a,b=[int(i) for i in input().split()]
  print(gcd(a,b),(a*b)//gcd(a,b))
 except EOFError:
  break

Submission status: Accepted

Solution code:
import sys

def gcd(a, b):
    "?????§??¬?´???°????±???????"
    if a < b:
        c = a
        a = b
        b = c
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

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

for line in sys.stdin:
    a, b = map(int, line.split())
    print("%d %d" % (gcd(a, b), lcm(a, b)))

Submission status: Accepted

Solution code:
import sys
dataset = sys.stdin.readlines()
 
 
def gcd(a, b):
    if b > a: return gcd(b, a)
    if a % b == 0: return b
    return gcd(b, a % b)
 
def lcd(a, b):
    return a * b // gcd(a, b)
 
for item in dataset:
    a, b = list(map(int, item.split()))
    print(gcd(a, b), lcd(a,b))

Submission status: Accepted

Solution code:
def GCD(a, b):
	if b > a:
		return GCD(b, a)
	elif a % b == 0:
		return b
	return GCD(b, a % b)
		
def LCM(a, b):
	return a * b // GCD(a, b)

import sys
L = sys.stdin.readlines()
for line in L:
	x, y = list(map(int, line.split()))
	print(GCD(x, y), LCM(x, y))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b!=0:
        c = b
        b = a % b
        a = c
    return a

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

def main():
    for line in sys.stdin:
        a, b = map(int, line.split())
        ng = gcd(a, b)
        nl = lcm(a, b, ng)
        print('{0:d} {1:d}'.format(int(ng), int(nl)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
    n = [int(i) for i in line.replace("\n", "").split(" ")]
    n.sort()
    low = n[0]
    hi = n[1]
    while hi % low:
        hi, low = low, hi % low
    print("%d %d" % (low, n[0] / low * n[1]))

Submission status: Accepted

Solution code:
def gcd(li):
    a=max(li)
    b=min(li)
    while b>0:
        a,b=b,a%b
    return a

def lcm(li):
    return li[0]*li[1]/gcd(li)

while True:
    try:
        li=[int(i) for i in input().split(" ")]
        print("%i %i"%(gcd(li),lcm(li)))
    except:break

Submission status: Accepted

Solution code:
def gcd(a, b):
    if a == 0 or b == 0:
        return 0
    while b != 0:
        a, b = b, a%b
    return a

while True:
    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    else:
        g = gcd(a,b)
        print(g, a*b//g)

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin:
    a,b = list(map(int,line.split()))
    ab = a*b
    while b: a,b = b,a%b
    print(a,ab//a)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
for line in sys.stdin:
    a, b = map(int, line.split())
    print gcd(a, b), a*b/gcd(a,b)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
[print("{} {}".format(gcd(*x), x[0] * x[1] // gcd(*x))) for x in [list(map(int, x.split())) for x in sys.stdin]]

Submission status: Accepted

Solution code:
import sys, fractions
[[print("{} {}".format(int(fractions.gcd(t[0], t[1])), int(t[0] * t[1] / fractions.gcd(t[0], t[1])))) for t in [[int(y) for y in x.split()]]] for x in sys.stdin]

Submission status: Accepted

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: Accepted

Solution code:
while True:
    try:
        a, b = map(int, input().split())
        if a < b:
            b, a = a, b
        x, y = a, b
        while b: a, b = b, a%b
        gcd = a
        lcm = (x*y)//gcd
        print(gcd, lcm)
    except:
        break

Submission status: Accepted

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

while True:
    try:
        a, b = list(map(float, input().split()))
    except EOFError:
        break
    if a >= b:
        a, b = b, a
    gcd = GCD(a, b) if b%a != 0 else a
    print("{0} {1}".format(int(gcd), int(a*b/gcd)))

Submission status: Accepted

Solution code:
#coding: utf-8

import sys

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

for line in sys.stdin:
    l = map(int,line.split())
    l.sort()
    a = l[0]
    b = l[1]
    print gojo(a,b),a*b/gojo(a,b)

Submission status: Accepted

Solution code:
while True:
    try:
        As,Bs = map(int,input().split())
        a,b = As, Bs
        while True:
            if a % b == 0:
                gcd = b
                break
            a,b = b, a % b
        print(gcd,int(As * Bs / gcd))
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys


def calc_gcd(x, y):
    """ ?????§??¬?´???°????¨?????????? """
    if y == 0:
        return x
    else:
        return int(calc_gcd(y, x % y))


def calc_lcm(x, y):
    """ ????°???¬?????°????¨?????????? """
    return int((x * y) / calc_gcd(x, y))


if __name__ == '__main__':
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        x, y = map(int, line.split(' '))
        print('{0} {1}'.format(calc_gcd(x, y), calc_lcm(x, y)))

Submission status: Accepted

Solution code:
def main():
    while True:
        try:
            a, b = map(int, input().split())
            
            gcd = rec(a, b)
            lcm = a * b / gcd

            print(gcd, int(lcm))
        except:
            break

def rec(i, j):
    if i % j == 0:
        return j
    return rec(j, i % j)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

while True:
    try:
        a,b=sorted(map(int,input().split()))
    except:
        break
    print(gcd(a,b),a//gcd(a,b)*b)

Submission status: Accepted

Solution code:
def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

while True:
    try:
        x,y=map(int,input().split())
    except:
        break
    print(gcd(x,y),x*y//gcd(x,y))

Submission status: Accepted

Solution code:
import fractions
while 1:
    try:
        a,b=map(int,input().split())
        c=fractions.gcd(a,b)
        print(c,(a*b)//c)
    except:break

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

import sys

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

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

array = []
for i in sys.stdin:
    array.append(i)

for i in range(len(array)):
    n, m = array[i].split()
    n, m = int(n), int(m)
    print(int(gcd(n, m)),int(lcm(n, m)))

Submission status: Accepted

Solution code:

import fractions
 
while 1:
    try:
        a, b = map(int, input().split())
        c = fractions.gcd(a, b)
        print(c, a * b // c)
    except:
        break

Submission status: Accepted

Solution code:
def rec(a, b):
    if b == 0:
        return a
    return rec(b, a % b)

def main():
    while True:
        try:
            i, j = map(int, input().split())

            gcd = rec(i, j)
            lcm = i * j // gcd

            print(gcd, lcm)
        except:
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    gcd = lambda n, m : gcd(m, n % m) if m != 0 else n
    while True:
        try:
            n, m = map(int, input().split())

            g = gcd(n, m)
            l = n * m // g

            print(g, l)
        except:
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import fractions as f
for l in sys.stdin.readlines():
	a,b=map(int,l.split())
	print f.gcd(a,b),a*b/f.gcd(a,b)

Submission status: Accepted

Solution code:
import sys

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

for line in sys.stdin.readlines():
    a, b = map(int, line.split())
    print(gcd(a, b), a * b // gcd(a, b))

Submission status: Accepted

Solution code:
import sys
import fractions

for line in sys.stdin.readlines():
    a, b = map(int, line.split())
    gcd = fractions.gcd(a, b)
    print(gcd, a * b // gcd)

Submission status: Accepted

Solution code:
import sys
 
def gcd(inta, intb):
    large = max(inta, intb)
    small = min(inta,intb)
    mod = large % small
    if mod ==0:
        return small
    else:
        return gcd(small, mod) 
     
def lcm(inta, intb, intgcd):
    return (inta * intb // intgcd)
 
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    c = gcd(a, b)
    print(c, lcm(a, b, c))

Submission status: Accepted

Solution code:
import sys

def to_i(e):
  return int(e)

def calc_gcd(a, b):
  if b > 0:
    return calc_gcd(b, a % b)
  else:
    return a

def calc_lcm(a, b):
  return ((a / calc_gcd(a, b)) * b)

while True:
  line = sys.stdin.readline()
  if not line: break
  a, b = map(to_i, line.rstrip().split(" "))
  gcd = calc_gcd(a, b)
  lcm = calc_lcm(a, b)
  print str(gcd) + " " + str(lcm)

Submission status: Accepted

Solution code:
def gcd(a,b):
    while True:
        if a > b:
            a %= b
        else:
            b %= a
        if a == 0 or b == 0:
            return max(a,b)

def lcm(a,b,g):
    return int(a*b/g)
from sys import stdin
for l in stdin:
    a,b = list(map(int,l.split()))
    g = gcd(a,b)
    print ("%s %s"%(g,lcm(a,b,g)))

Submission status: Accepted

Solution code:
import sys
 
nums = []
 
 
for line in sys.stdin:
    nums.append(line)
 
for i in range(len(nums)):
    input_line = nums[i].split(" ")
    a = int(input_line[0])
    b = int(input_line[1])
 
    if a > b:
        num_bigger = a
        num_smaller = b
    else:
        num_bigger = b
        num_smaller = a

    r = 1   #?????????
    while r > 0:
        r = num_bigger % num_smaller
        num_bigger = num_smaller
        num_smaller = r

    max_common_div = num_bigger
    min_common_mpl = int((a * b)/max_common_div)
 
    print(str(max_common_div) + " " + str(min_common_mpl))

Submission status: Accepted

Solution code:
import sys

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

for line in sys.stdin:
    a,b = map(int, line.split())
    if a<b:
        tem = a
        a = b
        b = tem
    gc = gcd(a,b)
    print(gc, a*b//gc)

Submission status: Accepted

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: Accepted

Solution code:
import sys

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

lines = sys.stdin.readlines()
for line in lines:
    a, b = map(int, line.split())
    m = max(a, b)
    n = min(a, b)
    print(gcd(m, n), m * n // gcd(m, n))

Submission status: Accepted

Solution code:
#coding:utf-8

import sys

def gcd(n):
    x = n[0]
    y = n[1]

    while y:
        x, y = y, x % y

    return x


def lcm(n):
    return int(n[0] * n[1] / gcd(n))


if __name__ == '__main__':

    lines = []

    for line in sys.stdin:
        if line == "\n":
            break
        else :
            lines.append([int(item) for item in line.split(" ")])

    for n in lines:
        print(str(gcd(n)) + " " + str(lcm(n)))

Submission status: Accepted

Solution code:
import sys

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return int(a*b / gcd(a,b))

for s in sys.stdin:
    a, b = map(int, s.split())
    
    print(gcd(a,b), lcm(a,b))

Submission status: Accepted

Solution code:
def gcd(a, b):
    while(b > 0):
        a, b = b, a % b
    return a
import sys
for line in sys.stdin:
    a, b = map(int, line.split())
    g = gcd(a, b)
    print(g, a * b // g)

Submission status: Accepted

Solution code:
import sys

def gcd(a,b):
	a,b=max(a,b),min(a,b)
	while a%b:
		a,b=b,a%b
	return b
	
def lcm(a,b):
	return a//gcd(a,b)*b
	
for i in sys.stdin:
	a,b=map(int,i.split())
	print(gcd(a,b),lcm(a,b))

Submission status: Accepted

Solution code:
while True:
    try: 
        a, b = map(int, input().split())
        cross = a * b

        if a < b:
            a, b = b, a
        while a % b != 0:
            a, b = b, a % b
        print(b, cross // b)
    except EOFError:
        break

Submission status: Accepted

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 True :
    try:
        a,b = map(int,raw_input().split())
        a,b = max(a,b), min(a,b)
        print "%d" % gcd(a,b),
        print "%d" % lcm(a,b)
    except EOFError:
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os

def gcd(a, b):
    # big - small
    while a != b:
        if a > b:
            a, b = b, a
        a, b = b - a, a
    return a

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

lst = sys.stdin.readlines()
for s in lst:
    a, b = map(int, s.split())
    G = gcd(a, b)
    L = lcm(a, b)
    print(G, L)

Submission status: Accepted

Solution code:
import sys

def get_input():
    return map(int, input().split(' '))

def gcd(i,j):
    if i > j:
        if i % j == 0:
            return j
        else:
            return gcd(j, i % j)
    else:
        if j % i == 0:
            return i
        else:
            return gcd(i, j % i)
    
def main():
    for line in sys.stdin:
        ls = list(map(int, line.split(' ')))
        g = gcd(ls[0], ls[1])
        print(g, int(ls[0]*ls[1]/g))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def gcd(a,b):
    big,small=max(a,b),min(a,b)
    while big%small!=0:
        big,small=small,big%small
    return small
 
def lcm(a,b):
    return int(a*b/gcd(a,b))
  
def main():
    while True:
        try:
            IN=input()
            val=IN.split()
            g=gcd(int(val[0]),int(val[1]))
            l=lcm(int(val[0]),int(val[1]))
 
            print(g,l)
        except:
            break
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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


while True:
    try:
        a, b = [int(i) for i in input().split()]
        print(gcd(a, b), lcm(a, b))
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
import fractions

lines = []
for line in sys.stdin:
    num = line.split(" ")
    a, b = int(num[0]), int(num[1])
    gcd = fractions.gcd(a, b)
    print("{0} {1:.0f}".format(gcd, (a*b)/gcd))

Submission status: Accepted

Solution code:
import sys

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

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

for line in sys.stdin:
    a,b = sorted(map(int, line.rstrip().split(' ')))
    print("{} {}".format(gcd(a,b),lcm(a,b)))

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
for line in sys.stdin:
    a, b = sorted(map(int, line.split()))
    print(gcd(a, b), (a * b) // gcd(a, b))

Submission status: Accepted

Solution code:
def gcd(x, y):
	if y == 0L:
		return x
	elif x < y:
		return gcd(y, x)
	else:
		ny = x % y
		return gcd(y, ny)

while True:
	try:
		inpt = map(long, raw_input().split())
		g = gcd(inpt[0], inpt[1])
		h = inpt[0] * inpt[1] / g
		print str(g) + ' ' + str(h)

	except:
		break

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

import sys

get = sys.stdin.read().split('\n')

for g in get:
	nums = list(map(int, g.split()))
	output = ''
	if (nums != []):
		# print(nums)
		[a, b] = nums
		while ((a != 0) and (b != 0)):
			larger = max([a, b])
			smaller = min([a, b])
			a = larger - smaller 
			b = smaller
		output += str(max([a, b])) + ' ' + str((nums[0]*nums[1])//max([a,b]))
		print(output)