s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s497593333
p00005
u009288816
1515077848
Python
Python
py
Accepted
10
4684
399
import sys def gcd(a,b): if(b): return gcd(b,(a%b)) else: return a def lcm(a,b): return a*b/gcd(a,b) a = "" for input in sys.stdin: a += input l = a.split() for i in range(0,len(l),2): if(int(l[i]) > int(l[i+1])): print gcd(int(l[i]),int(l[i+1])),lcm(int(l[i]),int(l[i+1])) else: print gcd(int(l[i+1]),int(l[i])),lcm(int(l[i+1]),int(l[i]))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,802
s698044065
p00005
u706217959
1515390750
Python
Python3
py
Accepted
20
5600
668
class GCD(): def __init__(self,a,b): self.a = a self.b = b def gcd(self): if self.a < self.b: self.a, self.b = self.b, self.a while self.b: self.a, self.b= self.b, self.a % self.b return self.a def print(self): lcm = self.a * self.b // self.gcd() print(self.gcd(), lcm) def main(): data =[] while 1: try: n = input().split() a = int(n[0]) b = int(n[1]) data.append(GCD(a, b)) except EOFError: break for array in data: array.print() if __name__ == "__main__": main()
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,803
s321055167
p00005
u264972437
1516013706
Python
Python3
py
Accepted
20
5612
696
def pd(n): i = 2 ans = [] while i ** 2 <= n: while n % i == 0: n /= i ans.append(i) i += 1 if n > 1: ans.append(n) return ans def gcd(a, b): gcd = 1 pd_a = pd(a) pd_b = pd(b) for i in pd_a: if i in pd_b: pd_b.remove(i) gcd *= i return int(gcd) def lcm(a, b): lcm = a pd_a = pd(a) pd_b = pd(b) for i in pd_a: if i in pd_b: pd_b.remove(i) for j in pd_b: lcm *= j return int(lcm) while True: try: s = input() a,b = [int(i) for i in s.split(' ')] except: break print(gcd(a, b), lcm(a, b))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,804
s935140766
p00005
u043254318
1516201313
Python
Python3
py
Accepted
30
5596
418
def get_input(): while True: try: yield ''.join(input()) except EOFError: break N = list(get_input()) for l in range(len(N)): a,b = [int(i) for i in N[l].split()] A = a B = b if(a<b): c = a a = b b = c while b > 0: nexta = b nextb = a % b a = nexta b = nextb g = a print(g, int(A*B/g))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,805
s440391822
p00005
u150984829
1516551595
Python
Python3
py
Accepted
20
5664
99
import math,sys for e in sys.stdin: a,b=list(map(int,e.split()));g=math.gcd(a,b) print(g,a*b//g)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,806
s953612884
p00005
u150984829
1516551970
Python
Python3
py
Accepted
20
5604
101
import sys for e in sys.stdin: g,d=a,b=list(map(int,e.split())) while d:g,d=d,g%d print(g,a*b//g)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,807
s984955497
p00005
u150984829
1516552103
Python
Python3
py
Accepted
20
5604
101
import sys for e in sys.stdin: a,b=list(map(int,e.split()));p=a*b while b:a,b=b,a%b print(a,p//a)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,808
s064347431
p00005
u803045841
1516564564
Python
Python3
py
Accepted
20
5600
144
import sys for e in sys.stdin: a, b = map(int, e.split()) p = a * b while b: a, b = b, a%b pass print (a,p//a)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,809
s950785733
p00005
u536089081
1517566531
Python
Python3
py
Accepted
30
5656
139
from sys import stdin from math import gcd for line in stdin: a, b = map(int, line.split()) g = gcd(a, b) print(g, a // g * b)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,810
s116133607
p00005
u328199937
1519037563
Python
Python3
py
Accepted
20
5596
334
while True: try: a, b = map(int, input().split(" ")) if a < b: key = a a = b b = key A = a B = b while a % b != 0: key = a % b a = b b = key key = int(A * B / b) print(b, key) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,811
s226175465
p00005
u780025254
1519186759
Python
Python3
py
Accepted
20
5600
240
def gcd(a, b): while b: 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: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,812
s506786308
p00005
u553148578
1519818346
Python
Python3
py
Accepted
20
5652
138
import math while True: try: a, b = map(int, input().split()) print(int(math.gcd(a,b)),(a*b) // int(math.gcd(a,b))) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,813
s291765113
p00005
u613534067
1520063971
Python
Python3
py
Accepted
20
5600
404
import sys # 最大公約数(greatest common divisor)を求める関数 def gcd(a, b): while b: a, b = b, a % b return a # 最小公倍数(least common multiple)を求める関数 # //は切り捨て除算 def lcm(a, b): return a * b // gcd(a, b) lines = sys.stdin.readlines() for line in lines: a = list(map(int, line.split(" "))) print(gcd(a[0], a[1]), lcm(a[0], a[1]))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,814
s922617134
p00005
u352394527
1523610933
Python
Python3
py
Accepted
30
5652
160
import math while True: try: a,b = list(map(int,input().split())) x = math.gcd(a,b) y = a * b // x print(x,y) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,815
s073990614
p00005
u027874809
1523930365
Python
Python3
py
Accepted
20
5596
425
while True: try: r = sorted(list(map(int, input().split()))) def euclidfunc(a, b): while b != 0: a, b = b, a % b return a def lcmfunc(a, b): return a * b // euclidfunc(a, b) print("{a} {b}".format(a=euclidfunc(r[1], r[0]), b=lcmfunc(r[1], r[0]))) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,816
s576359097
p00005
u533681846
1525024539
Python
Python3
py
Accepted
20
5600
240
while 1: try: a = list(map(int, input().split())) b=list(a) a.sort() while a[1]%a[0] != 0: a[1] %= a[0] a.sort() print(a[0], int(b[0]*b[1]/a[0])) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,817
s423415805
p00005
u533681846
1525024635
Python
Python3
py
Accepted
20
5656
149
import math while 1: try: a,b = map(int, input().split()) print(math.gcd(a,b), int(a*b/math.gcd(a,b))) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,818
s288120917
p00005
u724548524
1525731449
Python
Python3
py
Accepted
30
5600
238
import sys for i in sys.stdin: a, b = map(int, i.split()) p, q = max(a, b), min(a, b) while True: if p % q == 0: break else: p, q = q, p % q print("{} {}".format(q, int(a * b / q)))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,819
s435400915
p00005
u724548524
1525731499
Python
Python3
py
Accepted
30
5600
185
import sys for i in sys.stdin: a, b = map(int, i.split()) p, q = max(a, b), min(a, b) while p % q != 0: p, q = q, p % q print("{} {}".format(q, int(a * b / q)))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,820
s312003141
p00005
u945249026
1525772564
Python
Python3
py
Accepted
20
5604
232
def F(x, y): if x % y == 0: return y return F(y, x % y) while True: try: x, y = map(int,input().split()) print('{0} {1}'.format(F(x, y), int(x * y / F(x, y)))) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,821
s532265042
p00005
u223900719
1526209290
Python
Python
py
Accepted
10
4640
217
def gcd(a,b): if a%b==0: return b else: r=a%b return gcd(b,r) def lcm(a,b): return a*b/gcd(a,b) while True: try: a,b=map( int, raw_input().split() ) print gcd(a,b),lcm(a,b) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,822
s297404622
p00005
u940977872
1526366935
Python
Python3
py
Accepted
20
5656
193
import math while True: try: a, b = map(int, input().split()) gcd = math.gcd(a, b) lcm = (a * b) // gcd print(gcd, lcm) except Exception: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,823
s141649715
p00005
u802537549
1526808065
Python
Python3
py
Accepted
20
5676
207
import math while True: try: a, b = [int(i) for i in input().split()] gcd = math.gcd(a, b) lcm = a * b // gcd print(f'{gcd} {lcm}') except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,824
s426881058
p00005
u136916346
1527349898
Python
Python3
py
Accepted
20
5608
206
import sys def gcd(a,b): if a%b==0: return b return gcd(b,a%b) r=[list(map(int,line.split())) for line in sys.stdin] for i in r: o=gcd(i[0],i[1]) p=i[0]*i[1]/o print(o,int(p))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,825
s742326447
p00005
u986478725
1527571169
Python
Python3
py
Accepted
20
5596
729
# Vol0005. import sys def intinput(): a = input().split() for i in range(len(a)): a[i] = int(a[i]) return a def get_gcd(x, y): if x < y: return get_gcd(y, x) # x >= yのときはx % yを計算してyとx % yの話にする。 # ここでx % yのところが0ならばyが求める答えとなる。 if y == 0: return x return get_gcd(y, x % y) def main(): data = [] lines = sys.stdin.readlines() for line in lines: data.append(line.split()) N = len(data) for i in range(N): a = int(data[i][0]); b = int(data[i][1]) gcd = get_gcd(a, b) lcm = (a // gcd) * b print('%d %d' % (gcd, lcm)) if __name__ == "__main__": main()
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,826
s872021498
p00005
u002010345
1527725732
Python
Python3
py
Accepted
20
5600
256
def main(): while True: try: a,b=(int(x) for x in input().split()) except: break a1=a b1=b while b!=0: c=a%b a=b b=c print(a, a1*b1//a) main()
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,827
s301525293
p00005
u458530128
1528364589
Python
Python3
py
Accepted
20
5600
267
def f(x, y): if x % y == 0: return y return f(y, x % y) a = [] while True: try: a.append(list(map(int, input().split()))) except EOFError: break for i in a: g = f(i[0], i[1]) l = (i[0] * i[1]) / g print(g, int(l))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,828
s469508341
p00005
u847467233
1528506876
Python
Python3
py
Accepted
20
5604
309
# AOJ 0005 GCD and LCM # Python3 2018.6.9 bal4u def lcm(a, b): return a // gcd(a, b) * b def gcd(a, b): while b != 0: r = a % b a = b b = r return a while True: try: a = list(map(int, input().split())) print(gcd(a[0], a[1]), lcm(a[0], a[1])) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,829
s364346794
p00005
u328733599
1528535254
Python
Python3
py
Accepted
20
5652
340
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))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,830
s022552253
p00005
u563075864
1529164245
Python
Python3
py
Accepted
20
5600
245
import sys def euc(n,m): if max(n,m)%min(n,m) == 0: return min(n,m) else: return euc(min(n,m), max(n,m)%min(n,m)) for line in sys.stdin: a,b = [int(i) for i in line.split()] print(euc(a,b),int(a*b/euc(a,b)))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,831
s915568384
p00005
u650035614
1530634569
Python
Python3
py
Accepted
20
5596
382
def gcd(x, y): if x > y: x, y = y, x while x > 0: x, y = y%x, x return y def lcm(x, y): z = gcd(x, y) return x*y//z if __name__ == "__main__": while True: try: a, b = map(int, input().split()) g = gcd(a, b) l = lcm(a, b) print("{} {}".format(g, l)) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,832
s289049130
p00005
u995990363
1530677653
Python
Python3
py
Accepted
20
5600
424
import sys def gcd(a,b): while a % b != 0: a, b = b, a % b return b def lcm(a,b,g): _a = a // g _b = b // g return _a * _b * g def run(): data = [] for n in sys.stdin: a, b = list(map(int, n.split())) data.append((a,b)) for _data in data: a, b = _data g = gcd(a,b) l = lcm(a,b,g) print(g, l) if __name__ == '__main__': run()
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,833
s277479651
p00005
u263247628
1344422478
Python
Python
py
Accepted
10
4220
300
def gcd(a, b): r = a % b if r == 0: return b else: return gcd(b, r) def lcm(a, b): return a*b/gcd(a,b) while True: try: x = map(int, raw_input().split(" ")) print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1])) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,834
s260313632
p00005
u517745281
1344573558
Python
Python
py
Accepted
10
4236
189
import sys;print"\n".join("%d %d"%(lambda x:(x[2],x[0]/x[2]*x[1]))((lambda f,x:(x[0],x[1],f(f,x[0],x[1])))(lambda f,a,b:a%b==0 and b or f(f,b,a%b),map(int,s.split(' '))))for s in sys.stdin)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,835
s228514011
p00005
u108432367
1344659341
Python
Python
py
Accepted
10
4232
226
import sys def gcd(a,b): if b != 0: return gcd(b,a%b) else: return a def lcm(a,b,g): return b / g * a for s in sys.stdin: ls = map(int,s.split(' ')) print "%d %d" % (gcd(ls[0],ls[1]),lcm(ls[0],ls[1],gcd(ls[0],ls[1])))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,836
s541998475
p00005
u108432367
1344668980
Python
Python
py
Accepted
10
4232
191
import sys;print"\n".join("%d %d"%(lambda l:(l[0],l[2]/l[0]*l[1]))((lambda f,l:(f(f,l),l[0],l[1]))(lambda f,l:l[1]==0 and l[0] or f(f,[l[1],l[0]%l[1]]),map(int,s.split())))for s in sys.stdin)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,837
s674913748
p00005
u894941280
1344734738
Python
Python
py
Accepted
10
4228
257
def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def lcm(a,b): d = (a*b) / gcd(a,b) print d while True: try: x = map(int,raw_input().split(" ")) a,b = x[0],x[1] print gcd(a,b),(a*b)/gcd(a,b) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,838
s893580909
p00005
u891318575
1346476467
Python
Python
py
Accepted
10
4236
459
# -*- coding: utf-8 -*- while True: try: list = [int(x) for x in raw_input().split(" ")] list.sort(lambda x, y: y - x) gcd = lcm = 0 m = list[0] n = list[1] while True: r = m%n if r == 0: gcd = n break m = n n = r lcm = list[0] * list[1] / gcd print(str(gcd) + " " + str(lcm)) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,839
s849601045
p00005
u724947062
1346482030
Python
Python
py
Accepted
10
4232
356
import sys def gcd(a, b): if b == 0: return a else: r = a % b return gcd(b, r) def calc(a, b): gcd_val = gcd(a, b) lcm_val = a * b / gcd_val return (gcd_val, lcm_val) for line in sys.stdin.readlines(): line = line.strip() a, b = map(int, line.split()) print "{0[0]:d} {0[1]:d}".format(calc(a, b))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,840
s037935006
p00005
u894941280
1347477779
Python
Python
py
Accepted
10
4224
209
def gcd(a,b): if b == 0: return a return gcd(b,a%b) def lcm(c,d): return c*d/gcd(a,b) while True: try: a,b = map(int,raw_input().split()) c,d = a,b print gcd(a,b),lcm(c,d) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,841
s676917118
p00005
u126791750
1350217868
Python
Python
py
Accepted
10
4224
291
#coding:UTF-8 def gcd(x,y): r = x % y if r==0: return y else: return gcd(y,r) def lcm(x,y): return x * y / gcd(x,y) while True: try: n = map(int, raw_input().split()) print "%d %d"%(gcd(n[0],n[1]),lcm(n[0],n[1])) except Exception: break;
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,842
s963089962
p00005
u647766105
1350910137
Python
Python
py
Accepted
20
4220
208
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) for i in sys.stdin.readlines(): a,b=map(int,i.split()) print "{} {}".format(gcd(a,b),lcm(a,b))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,843
s535208477
p00005
u719737030
1350912906
Python
Python
py
Accepted
10
5948
258
import sys def gcd(x,y): if(y>0): return gcd(y,x%y) else: return x def lcm(x,y): return x/gcd(x,y)*y for x in sys.stdin.readlines(): n = [float(y) for y in x.split()] print "%d %d" % (gcd(n[0], n[1]),(lcm(n[0], n[1])))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,844
s080178744
p00005
u779627195
1352373612
Python
Python
py
Accepted
10
4224
283
#coding: utf-8 def GCM(m, n): while 1: if n == 0: return m m -= (m/n)*n m,n = n,m while 1: try: a,b = map(int, raw_input().split()) x = GCM(a,b) y = a*b / x print "%d %d" % (x, y) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,845
s442904398
p00005
u504990413
1354020391
Python
Python
py
Accepted
10
5056
371
while True: try: x = map(int, raw_input().split(' ')) if x[0] < x[1]: m = x[1] n = x[0] else: m = x[0] n = x[1] # m is greatrer than n while n !=0: m,n = n,m % n print m,x[0]*x[1]/m except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,846
s499951888
p00005
u419407022
1355296643
Python
Python
py
Accepted
10
4996
371
def swap(a, b): a = a ^ b b = a ^ b a = a ^ b def gcd(x, y): if(x < y): swap(x, y) mod = x % y if mod == 0: return y else: return gcd(y, mod) def lcm(x, y): return x * y / gcd(x, y) while True: try: (a, b) = map(int ,raw_input().split()) except EOFError: break print gcd(a, b), lcm(a, b)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,847
s071234065
p00005
u665962315
1357422032
Python
Python
py
Accepted
10
4224
254
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, m): return a * b / gcd(a, b); while True: try: a, b = map(int, raw_input().split()) print gcd(a, b), lcm(a, b) except (EOFError): break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,848
s097921245
p00005
u560838141
1358755150
Python
Python
py
Accepted
20
4224
294
def gcd(a, b): r = a % b if r == 0: return b else: return gcd(b, r) def lcm(a, b): return a*b/gcd(a,b) while True: try: x = map(int, raw_input().split(" ")) print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1])) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,849
s334021130
p00005
u378761086
1360424919
Python
Python
py
Accepted
10
4232
266
#!/usr/bin/python import sys def gcd(a,b): if b == 0: return a else: return gcd(b, a%b) def lcm(a,b): return a / gcd(a,b) * b for l in sys.stdin: a = [int(s) for s in l.split()] print str(gcd(a[0],a[1]))+" "+str(lcm(a[0],a[1]))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,850
s941121630
p00005
u782850731
1361796217
Python
Python
py
Accepted
30
5900
386
from __future__ import (division, absolute_import, print_function, unicode_literals) import sys from fractions import gcd from itertools import count for line in sys.stdin: small, large = sorted(int(n) for n in line .split()) for i in count(large, large): if not i % small: lcm = i break print(gcd(large, small), lcm)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,851
s070497435
p00005
u782850731
1361802088
Python
Python
py
Accepted
20
5896
285
from __future__ import (division, absolute_import, print_function, unicode_literals) import sys from fractions import gcd for line in sys.stdin: small, large = sorted(int(n) for n in line .split()) G = gcd(large, small) print(G, large // G * small)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,852
s520107838
p00005
u743065194
1363003769
Python
Python
py
Accepted
10
4220
150
import sys def gcd(m,n): if n==0: return m return gcd(n,m%n) for l in sys.stdin: a,b=map(int,l.split()) d=gcd(a,b) print d,a/d*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,853
s622759677
p00005
u282635979
1363863189
Python
Python
py
Accepted
10
4228
323
while True: try: while True: ints = raw_input() if ints != '': x = map(int,ints.split(' ')) x.sort() a = x[1] b = x[0] while True: m=a%b if m!=0: a=b b=m continue else: break n = x[1]*x[0]/b print b,n continue else: break except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,854
s949520130
p00005
u585414111
1365344779
Python
Python
py
Accepted
20
4220
179
import sys def gcd(a,b): if (b == 0): return a return gcd(b,a%b) for line in sys.stdin: a,b = [int(x) for x in line.split()] d = gcd(a,b) print d,a*b/d
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,855
s641745360
p00005
u455516672
1365669846
Python
Python
py
Accepted
10
4220
142
import sys def g(a,b): if b==0: return a return g(b,a%b) for l in sys.stdin: a,b=map(int,l.split()) c=g(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,856
s411039679
p00005
u350508326
1367943890
Python
Python
py
Accepted
10
4236
332
while True: try: a = map(int,raw_input().split()) n = [a[0],a[1]] while True: if a[0] < a[1]: tmp = a[0] a[0] = a[1] a[1] = tmp a[0] = a[0] - a[1] if a[0] == 0: break b = n[0]*n[1]/a[1] print "%d %d" % (a[1],b) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,857
s065388113
p00005
u542421762
1368111306
Python
Python
py
Accepted
20
5892
324
import sys import fractions import re def lcm(a, b): return a / fractions.gcd(a, b) * b #input_file = open(sys.argv[1], "r") #for line in input_file: for line in sys.stdin: ab = map(int, re.split(" +", line)) a, b = tuple(ab) gcd_ab = fractions.gcd(a, b) lcm_ab = lcm(a, b) print gcd_ab, lcm_ab
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,858
s811894434
p00005
u093607836
1369118432
Python
Python
py
Accepted
10
4224
202
while True: try: n = map(int, raw_input().split()) a = max(n) b = min(n) ab = a * b while b != 0 : c = a % b a = b b = c print str(a) + " " + str(ab / a) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,859
s374964337
p00005
u843960735
1374702283
Python
Python
py
Accepted
10
4220
228
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) try : while True : (a,b) = map(int, raw_input().split()) print gcd(a,b), lcm(a,b) except EOFError : pass
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,860
s951266104
p00005
u536245846
1374762535
Python
Python
py
Accepted
10
4220
221
def gcd(a, b): while b > 0: a, b = b, a%b return a while True: try: a,b = map(int, raw_input().split()) c = gcd(a, b) print "{0} {1}".format(c, a*b/c) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,861
s250663836
p00005
u912573907
1375168696
Python
Python
py
Accepted
10
4228
229
import sys def gcd(a, b): return gcd(b, a % b) if a % b else b def lcm(a, b): return a * b / gcd(a, b) for line in sys.stdin: data = map(int, line.split()) a, b = data print "%d %d" % (gcd(a, b), lcm(a, b))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,862
s069524509
p00005
u912237403
1376732643
Python
Python
py
Accepted
10
4220
282
def gcm(a, b): if a<b: a,b = b,a if (a%b ==0): return b else: return gcm(b, a%b) def lcm(a, b): return a/gcm(a,b)*b while True: try: a, b = map(int, raw_input().split()) except: break print "%d %d" %(gcm(a,b), lcm(a,b))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,863
s378543817
p00005
u813384600
1379307874
Python
Python
py
Accepted
20
5888
179
import fractions while True: try: (a, b) = map(int, raw_input().split()) c = fractions.gcd(a, b) print c, ((a*b)/c) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,864
s531062257
p00005
u492005863
1381235265
Python
Python
py
Accepted
10
4220
278
# GCD and LCM import sys def gcd(x, y): while x != y: if x > y: x -= y else: y -= x return x datas = [] for line in sys.stdin: datas.append(map(int, line.split())) for data in datas: g = gcd(data[0], data[1]) print "{0} {1}".format(g, data[0] * data[1] / g)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,865
s477673521
p00005
u511257811
1381941955
Python
Python
py
Accepted
20
4208
351
import sys for line in sys.stdin: a, b = sorted(map(int, line.split(' '))) gcd = 1 d = 2 while a >= d: amod, bmod = a % d, b % d if amod == 0 and bmod == 0: gcd *= d a, b = a/d, b/d d = 2 continue else: d += 1 lcm = gcd * a * b print gcd, lcm
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,866
s178290764
p00005
u351182591
1382020654
Python
Python
py
Accepted
10
4220
439
while 1: try: a, b = map(int,raw_input().split()) except EOFError: break ac, bc = a, b while 1: if a < b: b = b - a elif b < a: a = a - b elif a == b: x = [a,ac*bc/a] print "{:.10g} {:.10g}".format(*x) break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,867
s664246336
p00005
u093607836
1384846829
Python
Python
py
Accepted
10
4204
180
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) for s in sys.stdin: i = map(int,s.split()) print gcd(*i), lcm(*i)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,868
s466731566
p00005
u912237403
1388821738
Python
Python
py
Accepted
10
4204
207
import sys def gcm(a, b): if a<b: a,b=b,a if (a%b==0): return b else: return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print "%d %d" %(c,a/c*b)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,869
s701205504
p00005
u912237403
1388822348
Python
Python
py
Accepted
10
4208
184
import sys def gcm(a,b): if a<b: a,b=b,a if (a%b==0): return b return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print "%d %d" %(c,a/c*b)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,870
s709229275
p00005
u912237403
1388822727
Python
Python
py
Accepted
20
4204
151
import sys def gcm(a,b): if a%b==0: return b return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,871
s873998857
p00005
u912237403
1388823167
Python
Python
py
Accepted
10
4208
170
import sys def gcm(a,b): if a%b==0: return b return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) if a<b:a,b=b,a c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,872
s708123270
p00005
u912237403
1388823328
Python
Python
py
Accepted
10
4204
168
import sys def gcm(a,b): if b==0: return a return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) if a<b:a,b=b,a c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,873
s044277436
p00005
u912237403
1388823388
Python
Python
py
Accepted
10
4204
149
import sys def gcm(a,b): if b==0: return a return gcm(b,a%b) for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,874
s642627968
p00005
u786185717
1389536205
Python
Python
py
Accepted
10
4204
184
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))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,875
s024415072
p00005
u912237403
1390119479
Python
Python
py
Accepted
20
4192
138
import sys def gcm(a,b): return gcm(b,a%b) if b else a for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,876
s850008764
p00005
u912237403
1390119602
Python
Python
py
Accepted
10
4200
146
import sys def gcm(a,b): x=gcm(b,a%b) if b else a return x for s in sys.stdin: a,b=map(int,s.split()) c=gcm(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,877
s534659452
p00005
u912237403
1390119685
Python
Python
py
Accepted
10
4200
130
import sys def g(a,b): x=g(b,a%b) if b else a return x for s in sys.stdin: a,b=map(int,s.split()) c=g(a,b) print c,a/c*b
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,878
s557666100
p00005
u230836528
1392096723
Python
Python
py
Accepted
30
4312
524
# -*- coding: utf-8 -*- import sys def isprime(n): for i in xrange(2, int(n ** 0.5)+1 ): if n % i == 0: return False return True outList = [] for line in sys.stdin.readlines(): List = map(int, line.strip().split()) [a, b] = List # LCM LCM = 1 i = 1 while( i <= min(a, b) ): i += 1 if not isprime(i): continue while(a % i == 0 and b % i == 0): LCM *= i a /= i b /= i # GCD GCD = List[0] * b print LCM, GCD
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,879
s726211273
p00005
u124909914
1392269330
Python
Python
py
Accepted
10
4220
289
gcd, lcm = [], [] while True: try: a, b = map(int, raw_input().split()) if a > b: m, n = a, b else: m, n = b, a while n != 0: m, n = n, m % n gcd.append(m) lcm.append(a * b / m) except EOFError: break for gcd, lcm in zip(gcd, lcm): print '%d %d' % (gcd, lcm)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,880
s003137888
p00005
u633068244
1393351051
Python
Python
py
Accepted
10
4208
273
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
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,881
s675319984
p00005
u855866586
1394194830
Python
Python
py
Accepted
20
4224
215
import sys def gcd(a,b): if b==0: return a else: return gcd(b,a%b) for line in sys.stdin: (a,b)=line.split(" ") a=eval(a) b=eval(b) g=gcd(a,b) print("%d %d" % (g,a*b/g))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,882
s683831321
p00005
u097334177
1394782148
Python
Python
py
Accepted
10
4212
338
def gcd(a, b): if a < b: a, b = b, a r = a % b if r == 0: return b else: return gcd(b, r) def lcm(a, b, g): return a * b / g while True: try: a, b = map(int, raw_input().split()) except EOFError: break g = gcd(a, b) print "{} {}".format(g, lcm(a,b,g))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,883
s664410163
p00005
u193025715
1395394184
Python
Python
py
Accepted
20
4220
310
def get_gcd(a,b): if a > b: a, b = b, a if b % a == 0: return a else: return get_gcd(a, b % a) def get_lcm(a,b,g): return a * b / g while True: try: a,b = map(int, sorted(raw_input().split())) GCD = get_gcd(a,b) LCM = get_lcm(a,b,GCD) print "{} {}".format(GCD, LCM) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,884
s158589610
p00005
u140201022
1395852292
Python
Python
py
Accepted
10
4204
215
import sys def gcd(a,b): while a%b: a,b=b,a%b return b def lcm(a,b): return a*b/gcd(a,b) for ab in sys.stdin: a,b=map(int, ab.split()) a,b=max(a,b),min(a,b) print gcd(a,b),lcm(a,b)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,885
s632011165
p00005
u491763171
1396339138
Python
Python
py
Accepted
20
5868
157
from fractions import gcd while 1: try: a, b = map(int, raw_input().split()) print gcd(a, b), a * b / gcd(a, b) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,886
s771760807
p00005
u246033265
1396604965
Python
Python
py
Accepted
20
4204
221
def gcd(a, b): return a if b == 0 else gcd(b, a % b) def lcm(a, b): return a / gcd(a, b) * b try: while True: a, b = map(int, raw_input().split()) print gcd(a, b), lcm(a, b) except: pass
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,887
s408064576
p00005
u708217907
1397881287
Python
Python
py
Accepted
10
4204
288
# coding:utf-8 import sys # 最大公約数 def gcd(a, b): while b > 0: 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()) gcd_num = gcd(a, b) lcm_num = lcm(a, b) print "%d %d"%(gcd_num, lcm_num)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,888
s153581221
p00005
u146816547
1398860151
Python
Python
py
Accepted
30
5872
159
import fractions while True: try: x,y = map(int,raw_input().split()) print '%d %d' % (fractions.gcd(x,y),x/fractions.gcd(x,y)*y) except EOFError: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,889
s691868243
p00005
u436634575
1401128366
Python
Python3
py
Accepted
30
6720
212
def gcd(a, b): while b: a, b = b, a % b return a while True: try: line = input() except: break a, b = map(int, line.strip().split()) g = gcd(a, b) print(g, a * b // g)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,890
s036439277
p00005
u557208833
1402200256
Python
Python
py
Accepted
10
4216
317
import sys def readint(): for line in sys.stdin: yield map(int,line.split()) def gcd(x,y): [x,y] = [max(x,y),min(x,y)] while 1: z = x % y if z == 0: break [x,y] = [y,z] return y for [x,y] in readint(): GCD = gcd(x,y) mx = x/GCD print GCD,mx*y
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,891
s478676308
p00005
u618672141
1403738679
Python
Python3
py
Accepted
30
6720
303
def gcd(u, v): if (v == 0): return u return gcd(v, u % v) def lcm(u, v): return (u * v) // gcd(u, v) while 1: try: inp = input() except EOFError: break else: u, v = inp.split(' ') u = int(u) v = int(v) print(gcd(u, v), lcm(u, v))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,892
s956329641
p00005
u747915832
1597074554
Python
Python3
py
Accepted
20
5656
166
import math while True: try: a, b = map(int, input().split()) except: break GCD = math.gcd(a, b) LCM = (a*b)//GCD print(GCD, LCM)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,893
s867453250
p00005
u525366883
1596069166
Python
Python3
py
Accepted
20
5596
210
def gcd(y, x): if x == 0: return y return gcd(x, y%x) try: while True: a, b = sorted(map(int, input().split()), reverse=True) print(gcd(a,b), a*b//gcd(a,b)) except: pass
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,894
s132189694
p00005
u986283797
1595818051
Python
Python3
py
Accepted
20
5664
215
# -*- coding: utf-8 -*- import math errerN=1 while errerN: try: a=list(map(int, input().split())) gcdN=math.gcd(a[0],a[1]) print(gcdN, int(a[0]*a[1]/gcdN)) except : errerN=0
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,895
s498899286
p00005
u599584311
1594992275
Python
Python3
py
Accepted
20
5600
274
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()) except EOFError : break a, b = max(a, b), min(a, b) x = gcd(a, b) print(x, a * b // x)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,896
s027786427
p00005
u819143290
1594812789
Python
Python3
py
Accepted
20
5596
347
#2-8 while True: try: def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) a = list(map(int,input().split())) a.sort() a.reverse() ans1 = gcd(a[0],a[1]) ans2 = int(a[0]*a[1]/ans1) print(ans1,ans2) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,897
s674732233
p00005
u240091169
1594781529
Python
Python3
py
Accepted
20
5592
274
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()) except EOFError : break a, b = max(a, b), min(a, b) x = gcd(a, b) print(x, a * b // x)
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,898
s897720467
p00005
u537939262
1594099726
Python
Python3
py
Accepted
20
5596
238
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(gcd(a,b),lcm(a,b)) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,899
s708959658
p00005
u199192481
1594089785
Python
Python3
py
Accepted
20
5596
306
while True: 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) try: a, b = map(int, input().split()) except EOFError: break print(str(gcd(b, a%b)) + " " + str(int(lcm(a, b))))
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,900
s906553828
p00005
u187074069
1592189147
Python
Python3
py
Accepted
20
5616
296
while True: try: lst = list(map(int, input().split())) a, b = lst[0], lst[1] while b != 0: a, b = b, a % b c = lst[0]* lst[1]/ a print('{:.0f}'.format(a), end = " ") print('{:.0f}'.format(c)) except: break
p00005
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF. </p> <h2>Constraints</h2> <ul> <li> 0 &lt; <var>a, b</var> &le; 2,000,000,000</li> <li> LCM(<var>a, b</var>) &le; 2,000,000,000</li> <li> The number of data sets &le; 50</li> </ul> <H2>Output</H2> <p> For each data set, print GCD and LCM separated by a single space in a line. </p> <H2>Sample Input</H2> <pre> 8 6 50000000 30000000 </pre> <H2>Output for the Sample Input</H2> <pre> 2 24 10000000 150000000 </pre>
8 6 50000000 30000000
2 24 10000000 150000000
3,901