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
s039628413
p00005
u779577827
1479474785
Python
Python3
py
Accepted
50
10012
183
import sys, fractions [[print("{} {}".format(int(fractions.gcd(t[0], t[1])), int(t[0] * t[1] / fractions.gcd(t[0], t[1])))) for t in [[int(y) for y in x.split()]]] for x in sys.stdin]
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,702
s381983597
p00005
u542645301
1479479613
Python
Python3
py
Accepted
60
10100
170
import sys from fractions import gcd [print("{} {}".format(gcd(k[0], k[1]), (k[0] * k[1]) // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]
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,703
s350387228
p00005
u542645301
1479479696
Python
Python3
py
Accepted
50
10112
170
import sys from fractions import gcd [print("{} {}".format(gcd(k[0], k[1]), (k[0] * k[1]) // gcd(k[0], k[1]))) for i in sys.stdin for k in [[int(j) for j in i.split()]]]
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,704
s077070089
p00005
u546285759
1480413740
Python
Python3
py
Accepted
20
7568
245
while True: try: a, b = map(int, input().split()) if a < b: b, a = a, b x, y = a, b while b: a, b = b, a%b gcd = a lcm = (x*y)//gcd print(gcd, lcm) except: break
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,705
s473656306
p00005
u123687446
1480656146
Python
Python3
py
Accepted
30
7468
306
def GCD(a, b): b %= a return b if a%b == 0 else GCD(b, a) while True: try: a, b = list(map(float, input().split())) except EOFError: break if a >= b: a, b = b, a gcd = GCD(a, b) if b%a != 0 else a print("{0} {1}".format(int(gcd), int(a*b/gcd)))
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,706
s231919869
p00005
u166860661
1480774106
Python
Python
py
Accepted
10
6328
245
#coding: utf-8 import sys def gojo(a,b): if b % a == 0: return a else: return gojo(b % a, a) for line in sys.stdin: l = map(int,line.split()) l.sort() a = l[0] b = l[1] print gojo(a,b),a*b/gojo(a,b)
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,707
s340687312
p00005
u301729341
1481121906
Python
Python3
py
Accepted
30
7484
275
while True: try: As,Bs = map(int,input().split()) a,b = As, Bs while True: if a % b == 0: gcd = b break a,b = b, a % b print(gcd,int(As * Bs / gcd)) except EOFError: break
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,708
s540561906
p00005
u811733736
1481151140
Python
Python3
py
Accepted
30
7552
476
import sys def calc_gcd(x, y): """ ?????§??¬?´???°????¨?????????? """ if y == 0: return x else: return int(calc_gcd(y, x % y)) def calc_lcm(x, y): """ ????°???¬?????°????¨?????????? """ return int((x * y) / calc_gcd(x, y)) if __name__ == '__main__': # ??????????????\?????¨??????????????? for line in sys.stdin: x, y = map(int, line.split(' ')) print('{0} {1}'.format(calc_gcd(x, y), calc_lcm(x, y)))
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,709
s881464284
p00005
u811773570
1481257008
Python
Python3
py
Accepted
20
7524
340
def main(): while True: try: a, b = map(int, input().split()) gcd = rec(a, b) lcm = a * b / gcd print(gcd, int(lcm)) except: break def rec(i, j): if i % j == 0: return j return rec(j, i % j) if __name__ == '__main__': main()
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,710
s272165987
p00005
u661290476
1482232975
Python
Python3
py
Accepted
30
7568
194
def gcd(a,b): if a%b==0: return b return gcd(b,a%b) while True: try: a,b=sorted(map(int,input().split())) except: break print(gcd(a,b),a//gcd(a,b)*b)
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,711
s930538282
p00005
u661290476
1483002413
Python
Python3
py
Accepted
30
7724
184
def gcd(x,y): if y==0: return x return gcd(y,x%y) while True: try: x,y=map(int,input().split()) except: break print(gcd(x,y),x*y//gcd(x,y))
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,712
s429034253
p00005
u078042885
1483857453
Python
Python3
py
Accepted
60
10104
143
import fractions while 1: try: a,b=map(int,input().split()) c=fractions.gcd(a,b) print(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,713
s340495810
p00005
u711765449
1483966700
Python
Python3
py
Accepted
20
7652
320
# -*- coding:utf-8 -*- import sys def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) array = [] for i in sys.stdin: array.append(i) for i in range(len(array)): n, m = array[i].split() n, m = int(n), int(m) print(int(gcd(n, m)),int(lcm(n, m)))
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,714
s061438724
p00005
u923668099
1483978739
Python
Python3
py
Accepted
60
10176
143
import fractions while 1: try: a,b=map(int,input().split()) c=fractions.gcd(a,b) print(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,715
s065541491
p00005
u923668099
1483978989
Python
Python3
py
Accepted
60
10252
165
import fractions while 1: try: a, b = map(int, input().split()) c = fractions.gcd(a, b) print(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,716
s584742810
p00005
u811773570
1484037553
Python
Python3
py
Accepted
30
7724
320
def rec(a, b): if b == 0: return a return rec(b, a % b) def main(): while True: try: i, j = map(int, input().split()) gcd = rec(i, j) lcm = i * j // gcd print(gcd, lcm) except: break if __name__ == '__main__': main()
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,717
s812636317
p00005
u811773570
1484054915
Python
Python3
py
Accepted
30
7656
292
def main(): gcd = lambda n, m : gcd(m, n % m) if m != 0 else n while True: try: n, m = map(int, input().split()) g = gcd(n, m) l = n * m // g print(g, l) except: break if __name__ == '__main__': main()
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,718
s990875030
p00005
u376883550
1484093964
Python
Python
py
Accepted
20
7808
121
import sys import fractions as f for l in sys.stdin.readlines(): a,b=map(int,l.split()) print f.gcd(a,b),a*b/f.gcd(a,b)
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,719
s775519131
p00005
u376883550
1484097985
Python
Python3
py
Accepted
20
7640
194
import sys def gcd(a, b): if b == 0: return a return gcd(b, a % b) for line in sys.stdin.readlines(): a, b = map(int, line.split()) print(gcd(a, b), a * b // gcd(a, b))
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,720
s665141564
p00005
u376883550
1484098113
Python
Python3
py
Accepted
60
10176
156
import sys import fractions for line in sys.stdin.readlines(): a, b = map(int, line.split()) gcd = fractions.gcd(a, b) print(gcd, a * b // gcd)
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,721
s322314093
p00005
u745277023
1484375489
Python
Python3
py
Accepted
30
7624
389
import sys def gcd(inta, intb): large = max(inta, intb) small = min(inta,intb) mod = large % small if mod ==0: return small else: return gcd(small, mod) def lcm(inta, intb, intgcd): return (inta * intb // intgcd) sets = sys.stdin.readlines() for line in sets: a, b = map(int, line.split()) c = gcd(a, b) print(c, lcm(a, b, c))
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,722
s452609878
p00005
u252414452
1485779946
Python
Python
py
Accepted
10
6252
370
import sys def to_i(e): return int(e) def calc_gcd(a, b): if b > 0: return calc_gcd(b, a % b) else: return a def calc_lcm(a, b): return ((a / calc_gcd(a, b)) * b) while True: line = sys.stdin.readline() if not line: break a, b = map(to_i, line.rstrip().split(" ")) gcd = calc_gcd(a, b) lcm = calc_lcm(a, b) print str(gcd) + " " + str(lcm)
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,723
s031326284
p00005
u519227872
1486657574
Python
Python3
py
Accepted
20
7636
320
def gcd(a,b): while True: if a > b: a %= b else: b %= a if a == 0 or b == 0: return max(a,b) def lcm(a,b,g): return int(a*b/g) from sys import stdin for l in stdin: a,b = list(map(int,l.split())) g = gcd(a,b) print ("%s %s"%(g,lcm(a,b,g)))
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,724
s298594543
p00005
u301461168
1487774666
Python
Python3
py
Accepted
30
7628
588
import sys nums = [] for line in sys.stdin: nums.append(line) for i in range(len(nums)): input_line = nums[i].split(" ") a = int(input_line[0]) b = int(input_line[1]) if a > b: num_bigger = a num_smaller = b else: num_bigger = b num_smaller = a r = 1 #????????? while r > 0: r = num_bigger % num_smaller num_bigger = num_smaller num_smaller = r max_common_div = num_bigger min_common_mpl = int((a * b)/max_common_div) print(str(max_common_div) + " " + str(min_common_mpl))
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,725
s089397247
p00005
u901080241
1488950342
Python
Python3
py
Accepted
30
7612
252
import sys def gcd(a,b): if a%b == 0: return b else: return gcd(b, a%b) for line in sys.stdin: a,b = map(int, line.split()) if a<b: tem = a a = b b = tem gc = gcd(a,b) print(gc, a*b//gc)
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,726
s353855838
p00005
u459418423
1488980710
Python
Python3
py
Accepted
20
7656
229
import sys def gcd(m, n): if n != 0: return gcd(n, m % n) else: return m for line in sys.stdin.readlines(): m, n = map(int, line.split()) g = gcd(m, n) l = m * n // g # LCM print(g, l)
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,727
s133455687
p00005
u810591206
1489037800
Python
Python3
py
Accepted
30
7672
268
import sys def gcd(m, n): r = m % n if r == 0: return n else: return gcd(n, r) lines = sys.stdin.readlines() for line in lines: a, b = map(int, line.split()) m = max(a, b) n = min(a, b) print(gcd(m, n), m * n // gcd(m, n))
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,728
s510327923
p00005
u318658123
1489406826
Python
Python3
py
Accepted
40
7616
433
#coding:utf-8 import sys def gcd(n): x = n[0] y = n[1] while y: x, y = y, x % y return x def lcm(n): return int(n[0] * n[1] / gcd(n)) if __name__ == '__main__': lines = [] for line in sys.stdin: if line == "\n": break else : lines.append([int(item) for item in line.split(" ")]) for n in lines: print(str(gcd(n)) + " " + str(lcm(n)))
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,729
s571285818
p00005
u623894175
1490413478
Python
Python3
py
Accepted
30
7684
214
import sys def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return int(a*b / gcd(a,b)) for s in sys.stdin: a, b = map(int, s.split()) print(gcd(a,b), lcm(a,b))
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,730
s688910518
p00005
u036236649
1490595719
Python
Python3
py
Accepted
20
7656
180
def gcd(a, b): while(b > 0): a, b = b, a % b return a import sys for line in sys.stdin: a, b = map(int, line.split()) g = gcd(a, b) print(g, a * b // g)
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,731
s371903079
p00005
u728901930
1490778200
Python
Python3
py
Accepted
30
7668
192
import sys def gcd(a,b): a,b=max(a,b),min(a,b) while a%b: a,b=b,a%b return b def lcm(a,b): return a//gcd(a,b)*b for i in sys.stdin: a,b=map(int,i.split()) print(gcd(a,b),lcm(a,b))
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,732
s573331362
p00005
u631113523
1491673444
Python
Python3
py
Accepted
20
7488
245
while True: try: a, b = map(int, input().split()) cross = a * b if a < b: a, b = b, a while a % b != 0: a, b = b, a % b print(b, cross // b) except EOFError: break
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,733
s016723439
p00005
u307520683
1491891649
Python
Python
py
Accepted
10
6148
294
def gcd(a,b): while a%b : a,b=b,a%b return b def lcm(a,b): return a*b/gcd(a,b) while True : try: a,b = map(int,raw_input().split()) a,b = max(a,b), min(a,b) print "%d" % gcd(a,b), print "%d" % lcm(a,b) except EOFError: break
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,734
s173770249
p00005
u462831976
1492547679
Python
Python3
py
Accepted
30
7656
348
# -*- coding: utf-8 -*- import sys import os def gcd(a, b): # big - small while a != b: if a > b: a, b = b, a a, b = b - a, a return a def lcm(a, b): return a * b // gcd(a, b) lst = sys.stdin.readlines() for s in lst: a, b = map(int, s.split()) G = gcd(a, b) L = lcm(a, b) print(G, L)
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,735
s551211575
p00005
u000317780
1493785409
Python
Python3
py
Accepted
20
7644
484
import sys def get_input(): return map(int, input().split(' ')) def gcd(i,j): if i > j: if i % j == 0: return j else: return gcd(j, i % j) else: if j % i == 0: return i else: return gcd(i, j % i) def main(): for line in sys.stdin: ls = list(map(int, line.split(' '))) g = gcd(ls[0], ls[1]) print(g, int(ls[0]*ls[1]/g)) if __name__ == '__main__': main()
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,736
s461208800
p00005
u395334793
1493910573
Python
Python3
py
Accepted
30
7596
442
def gcd(a,b): big,small=max(a,b),min(a,b) while big%small!=0: big,small=small,big%small return small def lcm(a,b): return int(a*b/gcd(a,b)) def main(): while True: try: IN=input() val=IN.split() g=gcd(int(val[0]),int(val[1])) l=lcm(int(val[0]),int(val[1])) print(g,l) except: break if __name__ == '__main__': main()
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,737
s979368235
p00005
u362104929
1494589031
Python
Python3
py
Accepted
20
7600
261
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return (a * b) // gcd(a,b) while True: try: a, b = [int(i) for i in input().split()] print(gcd(a, b), lcm(a, b)) except EOFError: break
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,738
s967553335
p00005
u717959831
1494897860
Python
Python3
py
Accepted
50
10072
202
import sys import fractions lines = [] for line in sys.stdin: num = line.split(" ") a, b = int(num[0]), int(num[1]) gcd = fractions.gcd(a, b) print("{0} {1:.0f}".format(gcd, (a*b)/gcd))
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,739
s255177695
p00005
u922489088
1496019400
Python
Python3
py
Accepted
20
7572
271
import sys def gcd(a,b): r= b % a while r != 0: a,b = r,a r = b % a return a def lcm(a,b): return int(a*b/gcd(a,b)) for line in sys.stdin: a,b = sorted(map(int, line.rstrip().split(' '))) print("{} {}".format(gcd(a,b),lcm(a,b)))
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,740
s974651890
p00005
u905313459
1496059942
Python
Python3
py
Accepted
60
10156
144
import sys from fractions import gcd for line in sys.stdin: a, b = sorted(map(int, line.split())) print(gcd(a, b), (a * b) // gcd(a, b))
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,741
s356001045
p00005
u421983421
1496061720
Python
Python
py
Accepted
10
6608
273
def gcd(x, y): if y == 0L: return x elif x < y: return gcd(y, x) else: ny = x % y return gcd(y, ny) while True: try: inpt = map(long, raw_input().split()) g = gcd(inpt[0], inpt[1]) h = inpt[0] * inpt[1] / g print str(g) + ' ' + str(h) except: break
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,742
s213956671
p00005
u974788383
1496154473
Python
Python3
py
Accepted
30
7516
393
#! /usr/bin/env python3 import sys get = sys.stdin.read().split('\n') for g in get: nums = list(map(int, g.split())) output = '' if (nums != []): # print(nums) [a, b] = nums while ((a != 0) and (b != 0)): larger = max([a, b]) smaller = min([a, b]) a = larger - smaller b = smaller output += str(max([a, b])) + ' ' + str((nums[0]*nums[1])//max([a,b])) print(output)
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,743
s988876892
p00005
u440180827
1496889434
Python
Python3
py
Accepted
30
7488
271
import sys def gcd(a, b): for i in range(1, a+1): if a % i == 0: t = a // i if b % t == 0: return t for line in sys.stdin: a, b = sorted(map(int, line.split())) gcdab = gcd(a, b) print(gcdab, a // gcdab * 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,744
s158411796
p00005
u440180827
1496889584
Python
Python3
py
Accepted
20
7620
271
import sys def gcd(a, b): for i in range(1, a+1): if a % i == 0: t = a // i if b % t == 0: return t for line in sys.stdin: a, b = sorted(map(int, line.split())) gcdab = gcd(a, b) print(gcdab, a // gcdab * 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,745
s458886331
p00005
u503263570
1499697443
Python
Python3
py
Accepted
20
7608
129
import sys a=[map(int,i.split())for i in sys.stdin] for i,j in a: c,d=i,j while d: if c > d:c,d = d,c d%=c print(c,i//c*j)
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,746
s561772211
p00005
u503263570
1499697480
Python
Python3
py
Accepted
20
7664
125
import sys a=[map(int,i.split())for i in sys.stdin] for i,j in a: c,d=i,j while d: if c>d:c,d=d,c d%=c print(c,i//c*j)
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,747
s855554734
p00005
u503263570
1499697524
Python
Python3
py
Accepted
20
7604
129
import sys a=[map(int,i.split())for i in sys.stdin] for i,j in a: c,d=i,j while d: if c > d:c,d = d,c d%=c print(c,i//c*j)
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,748
s637928489
p00005
u600821328
1499945031
Python
Python3
py
Accepted
30
7744
317
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys def gcd(a, b): if b == 0: return a return gcd(b, a % b) def main(): for line in sys.stdin: a, b = map(int, line.split()) d = gcd(a, b) m = a * b // d print("{} {}".format(d, m)) 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,749
s276679462
p00005
u184989919
1500120776
Python
Python3
py
Accepted
20
7588
314
import sys def GcdLCM(): for line in sys.stdin: x,y=map(int,line.split()) if x==None: break gcd = Gcd(x,y) lcm = int(x*y/gcd) print("{} {}".format(gcd,lcm)) def Gcd(x,y): while x!=0: x,y=y%x,x return y GcdLCM()
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,750
s946519215
p00005
u806182843
1500211694
Python
Python3
py
Accepted
20
7708
182
def main(): import sys for line in sys.stdin: a, b = map(int, line.split()) c = a*b while a % b != 0: a, b = b, a%b print(b, c//b) 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,751
s864145550
p00005
u546285759
1500499285
Python
Python3
py
Accepted
20
7516
155
while True: try: a, b = map(int, input().split()) except: break ab = a*b while b: a, b = b, a%b print(a, ab//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,752
s200202868
p00005
u011621222
1500521973
Python
Python3
py
Accepted
30
7660
966
# Aizu - 0005 def De(a): res = [] tmp = 2 while a != 1: while not (a % tmp): a = round(a / tmp) res.append(tmp) tmp += 1 return res while True: try: tmp = input() a = [int(i) for i in tmp.split(' ')] except: break b = De(a[1]) a = De(a[0]) pa, pb = 0, 0 GCD, LCM = 1, 1 while True: if pa == len(a): for i in range(pb, len(b)): LCM *= b[i] break; if pb == len(b): for i in range(pa, len(a)): LCM *= a[i] break; if a[pa] == b[pb]: GCD *= a[pa] LCM *= a[pa] pa += 1 pb += 1 continue if a[pa] < b[pb]: LCM *= a[pa] pa += 1 continue if a[pa] > b[pb]: LCM *= b[pb] pb += 1 continue 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,753
s956430230
p00005
u354053070
1501902332
Python
Python3
py
Accepted
20
7724
243
import sys def gcd(x, y): if x < y: x, y = y, x while y > 0: x, y = y, x % y return x for line in sys.stdin: a, b = list(map(int, line.split())) print("{0} {1}".format(gcd(a, b), int((a * b) / gcd(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,754
s691249826
p00005
u214404619
1502748365
Python
Python3
py
Accepted
20
7664
236
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 line in sys.stdin: [a, b] = [int(num) for num in line.split()]; print(str(gcd(a, b)) + ' ' + str(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,755
s727558420
p00005
u584777171
1502933868
Python
Python3
py
Accepted
20
7644
344
import fileinput for line in fileinput.input(): tokens = list(map(int, line.strip().split())) a, b = tokens[0], tokens[1] d = a * b if a < b: tmp = a a = b b = tmp c = a % b while(c != 0): a = b b = c c = a % b g = b l = d / g print(str(g)+" "+str(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,756
s932589802
p00005
u299798926
1502951920
Python
Python3
py
Accepted
20
7588
293
while 1: try: x,y=[int(i) for i in input().split()] a=x b=y while 1: c=x%y if x%y==0: print(y,a*b//y) break else: x=y y=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,757
s471759957
p00005
u821624310
1502960953
Python
Python3
py
Accepted
30
7692
223
def gcd(a, b): if b == 0: return a return gcd(b, a % b) import fileinput import math for line in fileinput.input(): a, b = map(int, line.split()) g = gcd(a, b) lcm = a * b // g print(g, 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,758
s892984511
p00005
u234052535
1503226326
Python
Python3
py
Accepted
30
7660
494
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): for i in range(max([a, b]), a*b + 1): if(i % a == 0 and i % b == 0): return i return a*b for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(min(line), max(line)) print(str(g) + " " + str(line[0]*line[1]//g)) # + str(lcm(line[0], line[1])) except: exit()
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,759
s919354997
p00005
u234052535
1503226485
Python
Python3
py
Accepted
20
7644
334
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): while b != 0: a, b = b, a % b return a for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(min(line), max(line)) print(str(g) + " " + str(line[0]*line[1]//g)) except: exit()
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,760
s768352466
p00005
u193453446
1503470782
Python
Python3
py
Accepted
20
7648
583
import sys def main(): """ ????????? """ MAX = 2000000000 istr = sys.stdin.read() wi = istr.splitlines() for i in wi: a, b = list(map(int,i.split())) if a < b: a, b = b, a """ ????????????????????????????????§?????§??¬?´???°????????? """ x = a y = b while y > 0: z = x % y x = y y = z """ a ??¨ b ????????? a ??¨ b ???????°???¬?´???°??§?????? """ l = a * b // x print("{} {}".format(x,l)) 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,761
s604421291
p00005
u508732591
1503619602
Python
Python3
py
Accepted
20
7640
163
import sys def gcd(m,n): return m if n==0 else gcd(n, m%n) for m,n in [map(int,x.split()) for x in list(sys.stdin)]: g = gcd(m,n) print(g,(m//g)*n)
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,762
s628947318
p00005
u508732591
1503619736
Python
Python3
py
Accepted
30
7564
161
import sys def gcd(m,n): return m if n==0 else gcd(n, m%n) for m,n in [map(int,x.split()) for x in list(sys.stdin)]: g = gcd(m,n) print(g,m//g*n)
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,763
s003060708
p00005
u508732591
1503619740
Python
Python3
py
Accepted
20
7560
161
import sys def gcd(m,n): return m if n==0 else gcd(n, m%n) for m,n in [map(int,x.split()) for x in list(sys.stdin)]: g = gcd(m,n) print(g,m//g*n)
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,764
s317922475
p00005
u508732591
1503620179
Python
Python3
py
Accepted
30
7636
139
import sys for m,n in [map(int,x.split()) for x in list(sys.stdin)]: g,r = m,n while r!=0: g,r = r,g%r print(g,m//g*n)
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,765
s364604404
p00005
u508732591
1503620184
Python
Python3
py
Accepted
20
7588
139
import sys for m,n in [map(int,x.split()) for x in list(sys.stdin)]: g,r = m,n while r!=0: g,r = r,g%r print(g,m//g*n)
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,766
s876228033
p00005
u508732591
1503620324
Python
Python3
py
Accepted
20
7536
130
import sys for s in sys.stdin: m,n = map(int,s.split()) g,r = m,n while r!=0: g,r = r,g%r print(g,m//g*n)
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,767
s977613982
p00005
u428982301
1503886003
Python
Python3
py
Accepted
30
7604
472
import sys def calc(i1, i2): a = i1 b = i2 if (i1 < i2): a = i2 b = i1 r = a % b while r != 0: a = b b = r r = a % b gcd = b lcm = (i1 * i2) / gcd return gcd, lcm for line in sys.stdin: datas =line.split() if (len(datas)): li = list(map(int, datas)) a = li[0] b = li[1] x, y = calc(a, b) print("%d %d" % (x, y)) else: 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,768
s215266997
p00005
u123964252
1504093934
Python
Python3
py
Accepted
60
10120
396
import fractions lst = [] for i in range(200): try: lst.append(input()) except EOFError: break nums = [list(map(int, elem.split(' '))) for elem in lst] # gcd res_gcd = [fractions.gcd(num[0], num[1]) for num in nums] # lcm res_lcm = [nums[i][0] * nums[i][1] // res_gcd[i] for i in range(len(nums))] for (a, b) in zip(res_gcd, res_lcm): 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,769
s889469259
p00005
u855694108
1504103023
Python
Python3
py
Accepted
20
7588
397
import sys def main(): for line in sys.stdin: a,b = map(int, line.split()) if a > b: a,b = b,a p = a * b #product while True: hoge = a a = b % a b = hoge if a == 0: gcd = b break lcm = p // gcd print(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,770
s793779455
p00005
u957021183
1504683852
Python
Python3
py
Accepted
40
7692
406
# Aizu Problem 0006: GCD and LCM # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def gcd(a, b): while b != 0: t = b b = a % b a = t return a def lcm(a, b): return (a * b) // gcd(a, b) for line in sys.stdin: a, b = [int(_) for _ in line.split()] 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,771
s191881532
p00005
u877201735
1505712179
Python
Python3
py
Accepted
20
7628
287
def gcd(a, b): if (a % b) == 0: return b return gcd(b, a%b) def lcd(a, b): return a * b // gcd(a, b) while True: try: nums = list(map(int, input().split())) print(gcd(nums[0], nums[1]), lcd(nums[0], nums[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,772
s776768724
p00005
u741801763
1505741979
Python
Python3
py
Accepted
20
7696
399
import fileinput as fi def gcd_euler(a,b): if b == 0: return a u = a v = b r = u % v while True: if r == 0:return v u = v v = r r = u % v if __name__ == "__main__": for line in fi.input(): a,b = list(map(int,line.strip().split())) if a > b:gcd=gcd_euler(a,b) else:gcd=gcd_euler(b,a) print(gcd,int((a*b)/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,773
s757776986
p00005
u933096856
1505799665
Python
Python3
py
Accepted
20
7644
231
try: while True: x=list(sorted(map(int, input().split()))) a=x[0] b=x[1] while b%a != 0: c=a a=b%a b=c print(a, x[0]*x[1]//a) 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,774
s486237781
p00005
u146816547
1506135376
Python
Python
py
Accepted
10
6452
271
def gcd(x, y): if y == 0: return x else: return gcd(y, x%y) def lcm(x,y): return x/gcd(x, y)*y while True: try: x, y = map(int, raw_input().split()) except EOFError: break print "%d %d" % (gcd(x, y), lcm(x, 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,775
s593776018
p00005
u197615397
1506156361
Python
Python3
py
Accepted
30
7704
133
import sys for line in sys.stdin: a, b = map(int, line.split()) n = a*b while b: a, b = b, a%b print(a, n//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,776
s275762819
p00005
u531482846
1506204348
Python
Python3
py
Accepted
20
7688
214
import sys def gcd(x, y): if y == 0: return x else: return gcd(y, x%y) def lcm(x, y): return x * y //gcd(x,y) for line in sys.stdin: x, y = map(int, line.split()) print(gcd(x, y), lcm(x,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,777
s681264892
p00005
u742505495
1507700378
Python
Python3
py
Accepted
50
7772
301
import math import sys while True: try: a,b = map(int, input().split()) p = a q = b while True: r = p%q if r == 0: x = q break else: p = q q = r i = 1 while True: if a*i%b == 0: y = a*i break else: i = i+1 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,778
s610754711
p00005
u256256172
1508402958
Python
Python3
py
Accepted
20
7760
268
import sys for line in sys.stdin: a,b = map(int, line.split()) if a < b: a,b = b,a def gcd(x,y): while y > 0: x,y = y,x%y return x def lcm(x,y): return x * y / gcd(x, y) print(gcd(a,b), 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,779
s280600470
p00005
u197670577
1508421507
Python
Python
py
Accepted
10
6448
237
#!/usr/bin/python # coding: utf-8 def gcd(a,b): while b != 0: a, b = b, a % b return a while True: try: a, b = map(int, raw_input().split()) except: break 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,780
s198228173
p00005
u422087503
1508810929
Python
Python3
py
Accepted
20
7724
208
import sys def lcm(a,b): return a*b//gcd(a,b) def gcd(a,b): while True: a,b = b,a%b if b==0: return a for line in sys.stdin: a,b = map(int, line.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,781
s912796776
p00005
u424041287
1509112499
Python
Python3
py
Accepted
20
7608
211
t = 0 while t == 0: try: x,y=[int(i) for i in input().split()] except: break else: a = x * y if x < y: x,y =y,x while y > 0: r = x % y x = y y = r print(str(x) + " " + str(int(a / 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,782
s739666546
p00005
u914007790
1509346651
Python
Python3
py
Accepted
20
7648
432
def gcd(a, b): while b != 0: y = a % b a = b b = y return a d = [] m = [] while True: try: a, b = map(int, input().split()) if a > b: num = gcd(a, b) elif a < b: num = gcd(b, a) else: num = a d.append(num) m.append(int(a*b/num)) except EOFError: break for i in range(len(d)): print(d[i], m[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,783
s432906507
p00005
u776758454
1510675619
Python
Python3
py
Accepted
60
10080
251
import sys import fractions def main(): dataset = sys.stdin.readlines() for data in dataset: a, b = map(int, data.split()) gcd_num = fractions.gcd(a, b) print('%d %d' % (gcd_num, a * b / gcd_num)) 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,784
s004111882
p00005
u917432951
1510722838
Python
Python3
py
Accepted
80
10220
219
import sys import fractions def lcm(a,b): return int(a*b/fractions.gcd(a,b)) if __name__ == '__main__': for line in sys.stdin: a,b = map(int,line.split()) print(int(fractions.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,785
s736724264
p00005
u488038316
1510918749
Python
Python
py
Accepted
10
6396
556
# -*-coding:utf-8 import fileinput def main(): for line in fileinput.input(): tokens = list(map(int, line.strip().split())) a, b = tokens[0], tokens[1] if a < b: a, b = b, a ansGCD = GreatestCommonDivisor(a, b) ansLCM = LeastCommonMultiple(a, b) print('{0} {1}'.format(ansGCD, ansLCM)) def GreatestCommonDivisor(a, b): while b: a, b = b, a%b return a def LeastCommonMultiple(a, b): return (a*b) / GreatestCommonDivisor(a, b) 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,786
s457592640
p00005
u742178809
1511330055
Python
Python3
py
Accepted
30
7636
317
import sys #from me.io import dup_file_stdin def gcd(x,y): t = x % y if(t==0): return y else: return gcd(y, t) #@dup_file_stdin def solve(): for line in sys.stdin: x,y = map(int,line.split(" ")) f = gcd(x,y) print("{} {}".format(f, x//f*y)) solve()
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,787
s165074072
p00005
u548155360
1512381440
Python
Python3
py
Accepted
20
5596
594
# coding=utf-8 def solve_gcd(number1: int, number2: int) -> int: two_list = [number1, number2] two_list.sort() if two_list[1] % two_list[0] == 0: return two_list[0] r = two_list[1] % two_list[0] return solve_gcd(two_list[0], r) def solve_lcm(number1: int, number2: int, number3: int) -> int: return number1*number2//number3 if __name__ == '__main__': while True: try: a, b = map(int, input().split()) except EOFError: break gcd = solve_gcd(a, b) lcm = solve_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,788
s679930026
p00005
u024715419
1513245624
Python
Python3
py
Accepted
20
5588
178
while True: try: a, b = map(int, input().split()) x, y = a, b while y: x, y = y, x%y print(x,int(a*b/x)) 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,789
s367649024
p00005
u846136461
1513435796
Python
Python
py
Accepted
10
4656
345
# coding: utf-8 while True: try: data = map(int, raw_input().split()) if data[0] > data[1]: a = data[0] b = data[1] else: a = data[1] b = data[0] r = 1 while r > 0: q = a / b r = a - b * q a = b b = r gcd = a lcm = data[0] * data[1] / 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,790
s805936040
p00005
u471400255
1513698916
Python
Python3
py
Accepted
20
5672
144
from math import gcd from sys import stdin for line in stdin: a,b = [int(i) for i in line.split()] g = gcd(a,b) 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,791
s713017278
p00005
u546285759
1513929680
Python
Python3
py
Accepted
20
5600
252
def GCD(m, n): while n: m, n = n, m % n return m while True: try: a, b = map(int, input().split()) except: break if a < b: a, b = b, a gcd = 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,792
s997164972
p00005
u480287988
1514101868
Python
Python3
py
Accepted
20
5596
247
import sys for i in sys.stdin: a,b=list(map(int, i.split())) d=a*b if a>b: temp=a a=b b=temp c=a%b while c!=0: a=b b=c c=a%b g=b l=int(d/g) print("{} {}".format(g,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,793
s131373758
p00005
u764789069
1514132400
Python
Python
py
Accepted
10
4632
236
def GCD(a,b): while (a % b) != 0: a,b = b, a%b return b def LCM(a,b): return a * b / GCD(a,b) while True: try: a,b =map(int,raw_input().split()) 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,794
s870913137
p00005
u298999032
1514247278
Python
Python3
py
Accepted
20
5596
220
import sys for i in sys.stdin: a,b=map(int,i.split()) if a<b:a,b=b,a def gcd(x,y): while y>0:x,y=y,x%y return x def lcm(x,y): return x*y/gcd(x,y) print(gcd(a,b),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,795
s741327405
p00005
u600263347
1514274635
Python
Python3
py
Accepted
20
5592
316
def main(): while True: try: a,b = map(int,input().split()) c = a*b if a < b: a,b = b,a while a%b != 0: a,b = b,a%b print(b,c//b) except EOFError: exit() 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,796
s427880809
p00005
u183079216
1514294894
Python
Python3
py
Accepted
20
5604
410
def gcd(a,b): if a > b: x = a y = b else: x = b y = a while y > 0: r = x % y x = y y = r return x def lcm(a,b,c): return int(a*b/c) while 1: try: a,b = [int(x) for x in input().split()] res_gcd = gcd(a,b) res_lcm = lcm(a,b,res_gcd) print('{} {}'.format(res_gcd,res_lcm)) 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,797
s160448290
p00005
u585035894
1514534670
Python
Python3
py
Accepted
20
5600
181
import sys def gcd(x, y): if x % y != 0: return gcd(y, x % y) return y for i in sys.stdin: x, y = map(int, i.split()) g = gcd(x,y) print(g, int(x*y/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,798
s237748259
p00005
u028347703
1514555827
Python
Python3
py
Accepted
20
5604
272
import sys def gcd(m, n): if n > m: m, n = n, m if n == 0: return m else: return gcd(n, m % n) for line in sys.stdin: try: a, b = [int(i) for i in line.split()] g = gcd(a, b) l = a * b / g print("%d %d" % (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,799
s824771522
p00005
u764789069
1514697315
Python
Python
py
Accepted
0
4632
236
def GCD(a,b): while (a % b) != 0: a,b = b, a%b return b def LCM(a,b): return a * b / GCD(a,b) while True: try: a,b =map(int,raw_input().split()) 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,800
s536145301
p00005
u273843182
1514719857
Python
Python3
py
Accepted
20
5596
182
def gcd(a,b): if a % b == 0: return b else: return gcd(b,a%b) while True: try: a,b = map(int,input().split()) d = gcd(max(a,b),min(a,b)) print(d,a*b//d) except: break
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,801