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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s388716206
|
p00005
|
u696166817
|
1409410845
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 721
|
while True:
try:
# a >=b
a, b = sorted(map(int, input().strip("\n").split(" ")), reverse=True)
d = a * b
# calc. gcm by ユークリッド互除法
while True:
c = a % b
# print("{0} {1} {2}".format(a, b, c))
if c == 0:
break
else:
a, b = sorted([b, a % b], reverse=True)
gcm = b
lcm = d / gcm
# print("gcm is {}".format(b))
print("{0:d} {1:d}".format(int(gcm), int(lcm)))
#print("{0} {1}".format(a, b))
#a, b = sorted([b, a % b], reverse=True)
#print("{0} {1}".format(a, b))
except EOFError:
break # escape from while loop
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,602
|
s676871032
|
p00005
|
u579833671
|
1410764761
|
Python
|
Python
|
py
|
Accepted
| 20
|
4224
| 345
|
def GCD(x, y):
if(x == 0):
return(y)
return(GCD(y % x, x))
def LCM(x, y):
return(x * y / GCD(x, y))
while(True):
try:
a = map(int, raw_input().split())
if(a[0] > a[1]):
a[0], a[1] = a[1], a[0]
print(GCD(a[0], a[1])),
print(LCM(a[0], a[1]))
except Exception:
break
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,603
|
s471180467
|
p00005
|
u703446356
|
1410971402
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 219
|
while True:
try:
[x, y] = map(int, raw_input().split())
if x < y:
a = y
b = x
else:
a = x
b = y
while a % b:
c = a % b
a = b
b = c
print "%d %d" % (b, x*y/b)
except (EOFError):
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,604
|
s382347874
|
p00005
|
u615353970
|
1411349581
|
Python
|
Python
|
py
|
Accepted
| 10
|
4212
| 220
|
import sys
def gcd(a,b):
while a%b :
a,b=b,a%b
return b
def lcm(a,b) :
return a*b/gcd(a,b)
for ab in sys.stdin:
a,b = map(int,ab.split())
a,b = max(a,b),min(a,b)
print "%d" % gcd(a,b),
print "%d" % 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,605
|
s442052527
|
p00005
|
u607831289
|
1416063577
|
Python
|
Python
|
py
|
Accepted
| 10
|
4208
| 305
|
import sys
for line in sys.stdin:
a, b = map(int, line.split())
A, B = min(a, b), max(a, b)
while True:
mod = B % A
if mod == 0:
gcd = A
break
else:
A, B = mod, A
lcm = gcd * (a / gcd) * (b / gcd)
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,606
|
s108100200
|
p00005
|
u506132575
|
1416103638
|
Python
|
Python
|
py
|
Accepted
| 20
|
4208
| 253
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def gcd( a, b ):
while b > 0:
a, b = b, a%b
return a
def lcm( a, b ):
return a*b/gcd( a, b )
for s in sys.stdin:
d = map(int, s.split())
a,b = d[0],d[1]
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,607
|
s649961189
|
p00005
|
u310737167
|
1416679319
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 239
|
def gcd(n, m):
while n!=0:
tmp = n
n = m % n
m = tmp
return m
while 1:
try:
n, m = map(int, input().split())
x = gcd(n, m)
print(x, int(n*m/x))
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,608
|
s729751320
|
p00005
|
u310737167
|
1416679589
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6728
| 210
|
def gcd(n, m):
while n:
n, m = m % n, n
return m
while 1:
try:
n, m = map(int, input().split())
g = gcd(n, m)
print(g, int(n*m/g))
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,609
|
s682851452
|
p00005
|
u162387221
|
1417517479
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 219
|
def gcd(a, b):
while b:
a, b = b, a % b
return a
while True:
try:
line = input()
except:
break
a, b = map(int, line.strip().split())
g = gcd(a, b)
print(g, a * b // g)
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,610
|
s953916803
|
p00005
|
u379499530
|
1418662481
|
Python
|
Python
|
py
|
Accepted
| 20
|
4208
| 332
|
while 1:
try:
a, b = map(int, raw_input().split())
if a > b: x, y = a, b
else: x, y = b, a
r = x % y
while (r != 0):
x = y
y = r
r = x % y
gcd = y
lcm = (a / gcd) * b
print str(gcd) + " " + str(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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,611
|
s307455414
|
p00005
|
u672822075
|
1418964523
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6724
| 144
|
def gcd(a,b):
while b: a,b=b,a%b
return a
while True:
try:
a,b = map(int,input().split())
print(gcd(a,b),a*b//gcd(a,b))
except:
break;
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,612
|
s817205162
|
p00005
|
u846356981
|
1419470827
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 268
|
import sys
def gcd(n, m):
while m:
n, m = m, n % m
return n
def lcm(x, y):
return int((x * y) / gcd(x, y))
for line in sys.stdin:
l = line.replace('\n', '')
a, b = l.split()
a = int(a)
b = int(b)
print(gcd(a, b), lcm(a, b))
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,613
|
s807019739
|
p00005
|
u342537066
|
1420705884
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 227
|
while True:
try:
a,b=map(int,input().split())
y=a*b
if b>a:
a,b=b,a
while a%b:
x=a
a,b=b,x%b
print(b,int(y/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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,614
|
s857108393
|
p00005
|
u334500775
|
1421473424
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6728
| 918
|
import sys
#最大公約数
def gcd(x, y):
s = x / y
r = x % y
if r == 0:
return y
else:
return gcd(y, r)
#最小公倍数
def lcm(x, y):
return x*y/gcd(x, y)
def main():
#print ("a")
for line in iter(sys.stdin.readline, ""):
#print (line)
#tmp = sys.stdin.readline().split(" ")
#print ("b")
tmp = line.split(" ")
a = int(tmp[0])
b = int(tmp[1])
#print ("a="+str(a))
#print ("b="+str(b))
#b = sys.stdin.readline()
#print ("d")
if a > b:
c = a
d = b
else:
c = b
d = a
print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))
#tmp = sys.stdin.readline()
#if len(tmp) == 1:
# break
#else:
# tmp = tmp.split(" ")
#print ("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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,615
|
s531063834
|
p00005
|
u334500775
|
1421474390
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 918
|
import sys
#最大公約数
def gcd(x, y):
s = x / y
r = x % y
if r == 0:
return y
else:
return gcd(y, r)
#最小公倍数
def lcm(x, y):
return x*y/gcd(x, y)
def main():
#print ("a")
for line in iter(sys.stdin.readline, ""):
#print (line)
#tmp = sys.stdin.readline().split(" ")
#print ("b")
tmp = line.split(" ")
a = int(tmp[0])
b = int(tmp[1])
#print ("a="+str(a))
#print ("b="+str(b))
#b = sys.stdin.readline()
#print ("d")
if a > b:
c = a
d = b
else:
c = b
d = a
print (str(gcd(c, d)) + " " + str(int(lcm(c,d))))
#tmp = sys.stdin.readline()
#if len(tmp) == 1:
# break
#else:
# tmp = tmp.split(" ")
#print ("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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,616
|
s363389679
|
p00005
|
u336443042
|
1421713125
|
Python
|
Python
|
py
|
Accepted
| 20
|
4200
| 245
|
while(1):
try:
i = raw_input()
a, b = map(int, i.split())
x, y = a, b
while(b != 0):
tmp = b
b = a % b
a = tmp
print a,
print x*y/a
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,617
|
s658715084
|
p00005
|
u422939201
|
1422531890
|
Python
|
Python
|
py
|
Accepted
| 10
|
4208
| 242
|
# -*- coding: utf-8 -*-
import sys
def gcd(a,b):
while a%b:
a,b = b,a%b
return b
def lcm(a,b):
return a*b/gcd(a,b)
for s in sys.stdin:
a,b = map(int,s.split())
a,b = max(a,b),min(a,b)
print gcd(a,b),lcm(a,b)
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,618
|
s400197197
|
p00005
|
u422939201
|
1422532201
|
Python
|
Python
|
py
|
Accepted
| 30
|
5880
| 233
|
# -*- coding: utf-8 -*-
import sys
import fractions
def lcm(a,b):
return a / fractions.gcd(a,b) * b
for s in sys.stdin:
a,b = map(int,s.split())
gcd_ab = fractions.gcd(a,b)
lcm_ab = lcm(a,b)
print gcd_ab,lcm_ab
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,619
|
s229344128
|
p00005
|
u567380442
|
1422532322
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6724
| 229
|
import sys
def gcd(a, b):
while b % a:
a, b = b % a, a
return a
def lcm(a, b):
return a * b // gcd(a, b)
for line in sys.stdin:
a, b = sorted(list(map(int, 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,620
|
s925341148
|
p00005
|
u442472098
|
1423229325
|
Python
|
Python3
|
py
|
Accepted
| 70
|
14752
| 177
|
#!/usr/bin/env python3
import sys
from fractions import gcd
for line in sys.stdin:
[a, b] = [int(x) for x in line.split()]
print(int(gcd(a, b)), int(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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,621
|
s976595098
|
p00005
|
u879226672
|
1423268846
|
Python
|
Python
|
py
|
Accepted
| 10
|
4216
| 284
|
def gcd(m,n):
while m%n>0:
m,n=n,m%n
else:
return n
while True:
try:
a,b = map(int,raw_input().split())
a,b = max(a,b),min(a,b)
g = gcd(a,b)
l = a*b/g
print "%d %d" % (g, l)
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,622
|
s583376546
|
p00005
|
u744114948
|
1423637323
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6732
| 253
|
#! /usr/lib/python3
def gcd(a,b):
if b == 0:
return a
else:
return gcd(b,a%b)
while True:
try:
a, b=map(int, input().split())
s=gcd(a,b)
print("{0} {1:.0f}".format(s,a*b/s))
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,623
|
s377624064
|
p00005
|
u744114948
|
1423637563
|
Python
|
Python3
|
py
|
Accepted
| 60
|
14756
| 196
|
#! /usr/lib/python3
import fractions
while True:
try:
a, b=map(int, input().split())
s=fractions.gcd(a,b)
print("{0} {1:.0f}".format(s,a*b/s))
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,624
|
s745559165
|
p00005
|
u349293999
|
1423845713
|
Python
|
Python
|
py
|
Accepted
| 10
|
4204
| 248
|
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
for line in sys.stdin.readlines():
num = map(int, line.strip().split())
print "%i %i"%(gcd(num[0],num[1]) , lcm(num[0],num[1]))
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,625
|
s785996369
|
p00005
|
u392445270
|
1424440956
|
Python
|
Python
|
py
|
Accepted
| 20
|
4208
| 237
|
while True:
try:
temp = [int(x) for x in raw_input().split()]
m = max(temp)
n = min(temp)
while True:
if n == 0:
print m, (temp[0]*temp[1])/m
break
else:
temp2 = n
n = m % n
m = temp2
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,626
|
s869598072
|
p00005
|
u839573768
|
1425085328
|
Python
|
Python
|
py
|
Accepted
| 10
|
4220
| 369
|
def GCD(a,b):
if b == 0:
return a
else:
r = a % b
return GCD(b, r)
while True:
try:
data = map(int, raw_input().split())
except:
break
if data[0] > data[1]:
a = data[0]
b = data[1]
else:
a = data[1]
b = data[0]
x = GCD(a, b)
y = a*b / x
print 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,627
|
s154745189
|
p00005
|
u180584272
|
1425470215
|
Python
|
Python
|
py
|
Accepted
| 10
|
4220
| 276
|
def gcd(a,b):
while a>0 and b>0:
if a<b:
b -= a
elif a>b:
a -= b
else:
return a
raise
def lcm(a,b):
return a*b/gcd(a,b)
while True:
try:
inp = raw_input()
except EOFError:
break
a, b = map((lambda x: int(x) ), inp.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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,628
|
s774985976
|
p00005
|
u540744789
|
1425627523
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 234
|
import sys
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
for ab in sys.stdin:
a,b=map(int,ab.split(" "))
if a<=b:
tmp = a
a = b
b = tmp
g = gcd(a,b)
l = a*b/g
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,629
|
s419397400
|
p00005
|
u040533857
|
1425976446
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6728
| 402
|
while True:
try:
spam=map(int, input().split(' '))
spam = [i for i in spam]
spam.sort()
cola = spam[0] * spam[1]
while True:
if spam[0] == 0:
print('{} {}'.format(spam[1],int(cola/spam[1])))
break
pre = spam[0]
spam[0] = spam[1] % spam[0]
spam[1] = pre
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,630
|
s653927191
|
p00005
|
u396642573
|
1429364680
|
Python
|
Python
|
py
|
Accepted
| 20
|
4208
| 295
|
def gcd(a,b):
r = a % b
while r > 0:
a = b
b = r
r = 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 str(gcd(a,b)) + " " + str(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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,631
|
s178303923
|
p00005
|
u886766186
|
1430315719
|
Python
|
Python
|
py
|
Accepted
| 10
|
4208
| 254
|
# coding: utf-8
import sys
def gcd(a, b):
while a % b:
a, b = b, a%b
return b
def lcm(a, b):
return a * b / gcd(a, b)
for n in sys.stdin:
a, b = map(int, n.split())
a, b = max(a, b), min(a,b)
print gcd(a, b), lcm(a, b)
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,632
|
s745082628
|
p00005
|
u009961299
|
1430854210
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6720
| 222
|
# -*- coding: utf-8 -*-
while True:
try:
( a, b ) = map ( int, input ( ).split ( ) )
except EOFError: break
( x, y ) = ( a, b )
while x != 0:
( x, y ) = ( y % x, x )
print ( "%s %s" % ( y, a * b // 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,633
|
s053365507
|
p00005
|
u067299340
|
1432168965
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 150
|
import sys
for n in sys.stdin:
l=map(int,n.split())
b=l[0]*l[1]
u=[max(l),min(l)]
while u[1]!=0:
u=[u[1],u[0]%u[1]]
print "%d %d"%(u[0],b/u[0])
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,634
|
s583583638
|
p00005
|
u067299340
|
1432169055
|
Python
|
Python
|
py
|
Accepted
| 10
|
4196
| 128
|
import sys
for n in sys.stdin:
u=map(int,n.split())
b=u[0]*u[1]
while u[1]!=0:u=[u[1],u[0]%u[1]]
print "%d %d"%(u[0],b/u[0])
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,635
|
s627790169
|
p00005
|
u067299340
|
1432169273
|
Python
|
Python
|
py
|
Accepted
| 20
|
4200
| 127
|
import sys
for n in sys.stdin:
u=map(int,n.split())
b=u[0]*u[1]
while u[1]!=0:u=[u[1],u[0]%u[1]]
print"%d %d"%(u[0],b/u[0])
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,636
|
s654751650
|
p00005
|
u067299340
|
1432169288
|
Python
|
Python
|
py
|
Accepted
| 10
|
4200
| 127
|
import sys
for n in sys.stdin:
u=map(int,n.split())
b=u[0]*u[1]
while u[1]!=0:u=[u[1],u[0]%u[1]]
print"%d %d"%(u[0],b/u[0])
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,637
|
s181649771
|
p00005
|
u024599888
|
1433403732
|
Python
|
Python3
|
py
|
Accepted
| 40
|
6728
| 233
|
#!/usr/bin/env python3
while(True):
try:
a,b=map(int, input().split())
except EOFError:
break
#euclidian algorithm
r=a%b
x,y=a,b
while(r>0):
x=y
y=r
r=x%y
gcd=y
lcm=int(a*b/gcd)
print("{0} {1}".format(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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,638
|
s792347346
|
p00005
|
u873482706
|
1434200456
|
Python
|
Python
|
py
|
Accepted
| 10
|
4224
| 564
|
import sys
def dividend(num, Q):
a = Q
b = (num / Q) * Q
Q = num - (num / Q) * Q
if num == b:
aaa(a)
return
dividend(a, Q)
def aaa(greatest_common_divisor):
least_common_multiple = num1 * num2 / greatest_common_divisor
print('%s %s' % (greatest_common_divisor, least_common_multiple))
return
for input_line in sys.stdin:
num1 = int(input_line.split(' ')[0])
num2 = int(input_line.split(' ')[1])
if num1 <= num2:
dividend(num2, num1)
elif num1 > num2:
dividend(num1, num2)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,639
|
s100640323
|
p00005
|
u492083164
|
1434901626
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6728
| 234
|
def GCD_cal(a,b):
if(b==0):
return(a)
a,b=b,a%b
return(GCD_cal(a,b))
while(True):
try:
a,b=map(int,input().split(" "))
except:
break
if(a<b):
a,b=b,a
GCD=GCD_cal(a,b)
LCM=int(a*b/GCD)
print("{0} {1}".format(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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,640
|
s592393420
|
p00005
|
u777299405
|
1439359911
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6724
| 198
|
def gcd(a, b):
while b:
a, b = b, a % b
return a
while True:
try:
a, b = map(int, input().split())
print(gcd(a, b), a * b // gcd(a, b))
except:
break
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,641
|
s914336626
|
p00005
|
u722431421
|
1439453624
|
Python
|
Python
|
py
|
Accepted
| 10
|
4212
| 386
|
# coding: utf-8
#Problem Name: GCD and LCM
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp
while True:
try:
a,b = map(int,raw_input().split(' '))
s,t = a,b
while True:
r = s % t
if not r:
LCM = t
break
else:
s,t = t,r
print LCM, a*b/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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,642
|
s151492802
|
p00005
|
u235282710
|
1444041849
|
Python
|
Python
|
py
|
Accepted
| 10
|
6328
| 339
|
def gcd(a, b):
"""Return greatest common divisor using Euclid's Algorithm."""
while b:
a, b = b, a % b
return a
def lcm(a, b):
"""Return lowest common multiple."""
return a * b // gcd(a, b)
try:
while True:
a, b = map(int, raw_input().split(' '))
print gcd(a, b), lcm(a, b)
except EOFError:
pass
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,643
|
s624257525
|
p00005
|
u140201022
|
1444233325
|
Python
|
Python
|
py
|
Accepted
| 10
|
6256
| 198
|
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
while 1:
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,644
|
s723465919
|
p00005
|
u948218832
|
1444551098
|
Python
|
Python
|
py
|
Accepted
| 10
|
6292
| 191
|
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
for line in sys.stdin:
a, b = map(int , line.split())
print 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,645
|
s050250706
|
p00005
|
u071010747
|
1445176378
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7660
| 463
|
# -*- coding:utf-8 -*-
def gcd(a,b):
big,small=max(a,b),min(a,b)
while big%small!=0:
big,small=small,big%small
return small
def lcm(a,b):
return int(a*b/gcd(a,b))
def main():
while True:
try:
IN=input()
val=IN.split()
g=gcd(int(val[0]),int(val[1]))
l=lcm(int(val[0]),int(val[1]))
print(g,l)
except:
break
if __name__ == '__main__':
main()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,646
|
s389150867
|
p00005
|
u802625365
|
1446249845
|
Python
|
Python
|
py
|
Accepted
| 10
|
6220
| 251
|
import sys
while True:
try:
a,b = map(int,raw_input().split())
tempa = a
tempb = b
while tempa % tempb != 0 :
tempa , tempb = (tempb,tempa%tempb)
gcd = tempb
lcm = a * b / gcd
print "%d %d" % ( gcd, lcm)
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,647
|
s446998646
|
p00005
|
u290226505
|
1446709142
|
Python
|
Python
|
py
|
Accepted
| 10
|
6424
| 155
|
import sys
for line in sys.stdin:
a, b = map(int, line.split())
c = a * b
while b:
a, b = b, a % b
print(str(a) + ' ' + str(c / 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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,648
|
s962954377
|
p00005
|
u775586391
|
1447950870
|
Python
|
Python3
|
py
|
Accepted
| 40
|
7676
| 247
|
import sys
def kouyakusuu(a,b):
A = max(a,b)
B = min(a,b)
d = A % B
if d == 0:
return B
else:
return kouyakusuu(B,d)
for line in sys.stdin.readlines():
a,b = map(int,line.split())
m = kouyakusuu(a,b)
n = a*b//m
print(m,n)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,649
|
s275695962
|
p00005
|
u461370825
|
1449734918
|
Python
|
Python
|
py
|
Accepted
| 10
|
6380
| 196
|
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
while True:
try:
a, b = map(int, raw_input().strip().split(' '))
print "%d %d" % (gcd(a, b), a*b/gcd(a, b))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,650
|
s684193415
|
p00005
|
u825618558
|
1450033921
|
Python
|
Python3
|
py
|
Accepted
| 70
|
7644
| 491
|
import sys
def gcd(a,b):
if a==b:
return a
while(b>0):
a,b = b,a%b
if b==0:
return a
def lcm(a,b):
n=1
m=1
while(n*a!=m*b):
if n*a>m*b:
m+=1
elif n*a<m*b:
n+=1
return n*a
lines = sys.stdin.readlines()
for line in lines:
line = line.split(" ")
inp = []
for i in line:
inp.append(int(i))
inp.sort()
a = inp[0]
b = inp[1]
print("%d %d" % (gcd(a,b),lcm(a,b)))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,651
|
s354030225
|
p00005
|
u282982700
|
1450077733
|
Python
|
Python
|
py
|
Accepted
| 10
|
6360
| 204
|
# coding: utf-8
import sys
def gcd(a, b):
m = a % b
if m == 0:
return b
return gcd(b, m)
for l in sys.stdin:
x, y = map(int, l.split())
g = gcd(x, y)
l = x * y / g
print g, l
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,652
|
s716892037
|
p00005
|
u609881501
|
1450261551
|
Python
|
Python3
|
py
|
Accepted
| 40
|
7760
| 335
|
import sys
list = sys.stdin.readlines()
e=0
GCD = 0
def Euclide(a, b):
if b == 0:
return a
if a < b:
tmp = a
a = b
b = tmp
e = a%b
return Euclide(b, e)
for i in list:
i = i.split(' ')
GCD = Euclide(int(i[0]), int(i[1]))
print(str(GCD)+" "+str(int(int(i[0])/GCD*int(i[1]))))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,653
|
s644606617
|
p00005
|
u512342660
|
1451572576
|
Python
|
Python
|
py
|
Accepted
| 10
|
6368
| 315
|
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b,gcdnum=0):
if gcdnum==0:
return a * b // gcd (a, b)
else:
return a * b // gcdnum
for line in sys.stdin:
a,b = map(int,line.split())
gcdnum = gcd(a,b)
print "%d %d"%(gcdnum,lcm(a,b,gcdnum))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,654
|
s180888429
|
p00005
|
u529386725
|
1452182095
|
Python
|
Python
|
py
|
Accepted
| 10
|
6360
| 200
|
import sys
def gcd(a, b):
if b == 0: return a
return gcd(b, a%b)
for line in sys.stdin:
a, b= map(int, line.split())
if a < b:
a, b = b, a
g = gcd(a,b)
print g, a*b/g
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,655
|
s769259066
|
p00005
|
u073564985
|
1452600227
|
Python
|
Python
|
py
|
Accepted
| 10
|
6344
| 489
|
import sys
def gcd(a,b):
if b== 0:return a
return gcd(b,a%b)
def return_lcm(a,b):
prime = gcd(a,b)
return prime*(a/prime)*(b/prime)
def solve():
a = []
for line in sys.stdin:
digit_list = line.split(' ')
new_list = []
for j in digit_list:
new_list.append(int(j))
a.append(new_list)
for data in a:
print str(gcd(data[0],data[1])) + ' ' + str(return_lcm(data[0],data[1]))
if __name__ == "__main__":
solve()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,656
|
s735046386
|
p00005
|
u580607517
|
1452733017
|
Python
|
Python
|
py
|
Accepted
| 10
|
6232
| 238
|
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a * b / gcd(a, b)
while True:
try:
a, b = map(int, raw_input().split())
except EOFError:
break
print "%d %d" % (gcd(a, b), lcm(a, b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,657
|
s933679176
|
p00005
|
u386731818
|
1455004676
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7680
| 253
|
# coding: utf-8
# Here your code !
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
for line in sys.stdin:
a, b = map(int, line.split())
print( str(gcd(a,b))+" "+str(lcm(a,b)) )
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,658
|
s588480652
|
p00005
|
u650459696
|
1455019260
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7756
| 357
|
import sys
ary=[]
ans=[]
def gcd(a,b):
x=sorted([a,b])
while x[1]%x[0]!=0:
dif=x[1]%x[0]
x[1]=x[0]
x[0]=dif
return x[0]
for i in sys.stdin:
ary.append(list(map(int,i.split())))
ans.append([gcd(*ary[-1]),int(ary[-1][0]*ary[-1][1]/gcd(*ary[-1]))])
for i in range(len(ans)):
print('{0:d} {1:d}'.format(*ans[i]))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,659
|
s488877311
|
p00005
|
u867824281
|
1456932081
|
Python
|
Python
|
py
|
Accepted
| 10
|
6444
| 322
|
while True:
try:
[x, y] = map(int, raw_input().split())
if x < y:
a = y
b = x
else:
a = x
b = y
while a % b:
c = a % b
a = b
b = c
print "%d %d" % (b, x*y/b)
except (EOFError):
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,660
|
s029805107
|
p00005
|
u766477342
|
1457177115
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7668
| 289
|
def gcd(a, b):
if a > b:
a, b = b, a
if a == 0:
return b
else:
return gcd(b % a, a)
try:
while 1:
a,b = list(map(int,input().split()))
c = gcd(a, b)
print('{} {}'.format(c,int(c * (a/c) * (b/c))))
except Exception:
pass
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,661
|
s799407605
|
p00005
|
u075836834
|
1457991600
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7620
| 214
|
def gcd(a,b):
a,b=max(a,b),min(a,b)
while b!=0:
a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
while True:
try:
x,y=map(int,input().split())
print(gcd(x,y),lcm(x,y))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,662
|
s892655837
|
p00005
|
u148101999
|
1458269151
|
Python
|
Python
|
py
|
Accepted
| 10
|
6228
| 223
|
import sys
for i in sys.stdin:
m, n = map(int, i.split())
t1, t2 = m, n
while True:
if m % n == 0:
break
m, n = n, m % n
a = n
b = (t1/ a) * t2
print("{} {}".format(a, b))
|
p00005
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a line. The input terminates with EOF.
</p>
<h2>Constraints</h2>
<ul>
<li> 0 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,663
|
s340260863
|
p00005
|
u915343634
|
1458318654
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7628
| 207
|
while(True):
try:
(a, b) = map(int, input().split(" "))
(x, y) = (a, b)
while (x != 0):
(x, y) = (y%x, x)
print("%s %s" %(y, a*b//y))
except:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,664
|
s122713376
|
p00005
|
u811773570
|
1459823435
|
Python
|
Python
|
py
|
Accepted
| 10
|
6384
| 298
|
#coding:utf-8
while True:
try:
a, b = map(int, raw_input(). split())
x = a * b
while True:
c = a % b
a = b
b = c
if b == 0:
break
x = x / a
print("%d %d" % (a, x))
except:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,665
|
s882970591
|
p00005
|
u130979865
|
1459855659
|
Python
|
Python
|
py
|
Accepted
| 10
|
6224
| 263
|
# -*- coding: utf-8 -*-
import sys
for line in sys.stdin:
a, b = map(int, line.split())
t1, t2 = a, b
while True:
if a%b:
a, b = b, a%b
else:
break
gcd = b
lcm = t1/gcd*t2
print "%d %d" %(gcd, lcm)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,666
|
s314229595
|
p00005
|
u572790226
|
1460084781
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7692
| 386
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,667
|
s740155215
|
p00005
|
u894114233
|
1461761267
|
Python
|
Python
|
py
|
Accepted
| 10
|
6416
| 230
|
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
def lcm(a,b,g):
return a*b/g
while 1:
try:
a,b=map(int,raw_input().split())
g=gcd(a,b)
print g,lcm(a,b,g)
except:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,668
|
s719905403
|
p00005
|
u648595404
|
1461931674
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7688
| 213
|
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a,b):
return a*b//gcd(a,b)
sets = sys.stdin.readlines()
for line in sets:
a, b = map(int, line.split())
print(gcd(a,b), lcm(a, b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,669
|
s301140190
|
p00005
|
u412890344
|
1464222145
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7676
| 1,090
|
def get_input():
while True:
try:
yield "".join(input())
except EOFError:
break
def calcGCD(a,b):#?????§??¬?´???°????±?????????????????????????????????????????????¨?????????
if a>b:
large = a
small = b
elif a<b:
large = b
small = a
else:
return a
while True:
if large == small:
return large
temp_small = large - small
if temp_small < small:
large = small
small = temp_small
else:
large = temp_small
small = small
def calcLCM(a,b,gcd):#????°???¬?????°????±??????????
lcm = a*b/gcd
return lcm
if __name__ == "__main__":
array = list(get_input())
for i in range(len(array)):
temp_a,temp_b = array[i].split()
a,b = int(temp_a),int(temp_b)
gcd = calcGCD(a,b)
lcm = calcLCM(a,b,gcd)
lcm = int(lcm)
print("{} {}".format(gcd,lcm))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,670
|
s395391076
|
p00005
|
u403901064
|
1464620737
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7596
| 327
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
while True:
try:
a, b = [int(x) for x in input().split(" ")]
except:
return
else:
print(gcd(a, b),lcm(a, b))
def lcm(a, b):
return (a * b) // gcd(a,b)
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
if __name__ == '__main__':
main()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,671
|
s250144866
|
p00005
|
u957021485
|
1465562736
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7684
| 282
|
import sys
dataset = sys.stdin.readlines()
def gcd(a, b):
if b > a: return gcd(b, a)
if a % b == 0: return b
return gcd(b, a % b)
def lcd(a, b):
return a * b // gcd(a, b)
for item in dataset:
a, b = list(map(int, item.split()))
print(gcd(a, b), lcd(a,b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,672
|
s341537607
|
p00005
|
u765849500
|
1466149305
|
Python
|
Python
|
py
|
Accepted
| 10
|
6344
| 214
|
import sys
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b / gcd(a, b)
for s in sys.stdin:
a, b = map(int, s.split())
print "%d %d"%(gcd(a, b), lcm(a, b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,673
|
s662786124
|
p00005
|
u203261375
|
1466633712
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7636
| 248
|
import sys
def gcd(a,b):
if a<b:
t = a
a = b
b = t
while b != 0:
temp = b
b = a%b
a = temp
return a
for i in sys.stdin:
a,b = map(int, i.split())
g = gcd(a,b)
print(g, a*b//g)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,674
|
s474401310
|
p00005
|
u617990214
|
1467205369
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7576
| 349
|
ans=[]
while True:
try:
k,l=list(map(int,input().split(" ")))
init_k=k
init_l=l
#
while True:
if k%l==0:
gcd=l
tmp_1=init_k/gcd
tmp_2=init_l/gcd
lcm=gcd*tmp_1*tmp_2
break
else:
tmp=k%l
k=l
l=tmp
gcd=int(gcd)
lcm=int(lcm)
ans.append(str(gcd)+" "+str(lcm))
except:
break
for i in ans:
print(i)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,675
|
s020961007
|
p00005
|
u454259029
|
1468079045
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7636
| 206
|
while True:
try:
(a, b) = map(int, input().split(" "))
(x, y) = (a, b)
while (x != 0):
(x, y) = (y%x, x)
print("%s %s" %(y, a*b//y))
except:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,676
|
s277840971
|
p00005
|
u896025703
|
1469451828
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7612
| 225
|
def gcd(a, b):
if b == 0: return a
else: return gcd(b, a % b)
def lcm(a, b):
return a * b / gcd(a, b)
while True:
try:
a, b = map(int, input().split())
print(int(gcd(a, b)), int(lcm(a, b)))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,677
|
s110221036
|
p00005
|
u436587708
|
1469603083
|
Python
|
Python
|
py
|
Accepted
| 10
|
6260
| 207
|
def gcd(a, b):
return gcd(b, a%b) if b else a
while True:
try:
a, b = map(int, raw_input().split())
ans = gcd(a, b)
print ans, a*b//ans
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,678
|
s537113689
|
p00005
|
u626838615
|
1469794065
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7628
| 247
|
def gcd(a,b):
while b != 0:
a , b = b , a % b
return a
def lcm(a,b):
return int(abs(a*b) / gcd(a,b))
while True:
try:
a, b = [int(x) for x in input().split()]
except:
exit()
print(gcd(a,b),lcm(a,b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,679
|
s692082649
|
p00005
|
u582608581
|
1470284127
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7420
| 272
|
def GcdLcm(a, b):
p = a * b
if a < b:
a, b = b, a
r = a % b
while r != 0:
a = b
b = r
r = a % b
return [b, int(p / b)]
while True:
try:
a, b = [eval(item) for item in input().split()]
g, l = GcdLcm(a, b)
print(str(g), str(l))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,680
|
s970523655
|
p00005
|
u358919705
|
1471814491
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7620
| 244
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,681
|
s232400621
|
p00005
|
u589886885
|
1471935883
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7636
| 314
|
import sys
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
def lcm(a, b):
return a * b // gcd(a, b)
def main():
for i in sys.stdin.readlines():
a, b = [int(x) for x in i.split()]
print(gcd(a, b), lcm(a, b))
if __name__ == '__main__':
main()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,682
|
s205750271
|
p00005
|
u350804311
|
1473226650
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7548
| 183
|
import sys
for s in sys.stdin:
a = list(map(int, s.split()))
b = a[0]
c = a[1]
while c != 0:
b, c = c, b%c
d = a[0] * a[1] / b
print(int(b), int(d))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,683
|
s931061991
|
p00005
|
u058433718
|
1474043820
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7652
| 565
|
import sys
def get_gcd(a, b):
if a < b:
a, b = b, a
if a % b == 0:
return b
else:
return get_gcd(b, a % b)
def get_lcm(a, b, gcd):
lcm = a * b // gcd
return lcm
def main():
while True:
data = sys.stdin.readline().strip()
if data is None or data == '':
break
nums = data.split(' ')
a = int(nums[0])
b = int(nums[1])
gcd = get_gcd(a, b)
lcm = get_lcm(a, b, gcd)
print(gcd, lcm)
if __name__ == '__main__':
main()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,684
|
s183593460
|
p00005
|
u393305246
|
1474193662
|
Python
|
Python
|
py
|
Accepted
| 70
|
6364
| 465
|
import sys
import math
a = []
for line in sys.stdin:
a.append(line)
for n in a:
inl=n.split()
num1=int(inl[0])
check=1
list=[]
while check<=math.sqrt(num1):
if num1%check==0:
list.append(check)
list.append(num1/check)
check+=1
list.sort()
list.reverse()
num2=int(inl[1])
for i in list:
if num2%i==0:
gud=i
break
lcm=num1*num2/gud
print gud,lcm
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,685
|
s971644278
|
p00005
|
u505912349
|
1475896840
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7704
| 259
|
import sys
temp = []
largest = 1
for line in sys.stdin:
a,b = [int(x) for x in line.split()]
if a > b:
x,y = a,b
else:
x,y = b,a
while y:
x,y = y,x%y
smallest = x * (a/x) * (b/x)
print('%d %d' % (x, smallest))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,686
|
s830777507
|
p00005
|
u090396561
|
1477159055
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7540
| 327
|
def gcd(x, y):
if x < y:
tmp = x
x = y
y = tmp
while True:
if y == 0:
break
x = x % y
tmp = x
x = y
y = tmp
return x
def lcm(x, y):
return x * y / gcd(x, y)
while True:
try:
a, b = map(int, input().split())
print(gcd(a, b), int(lcm(a, b)))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,687
|
s819664381
|
p00005
|
u813534019
|
1477161109
|
Python
|
Python
|
py
|
Accepted
| 10
|
6432
| 249
|
while True:
try:
a,b = map(int, raw_input().split())
x,y = (a,b) if a > b else (b,a)
while x%y:
m = x % y
x,y = y,m
print "%d %d" % (y, a*b/y)
except (EOFError):
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,688
|
s823452844
|
p00005
|
u813534019
|
1477161904
|
Python
|
Python
|
py
|
Accepted
| 10
|
6260
| 162
|
import sys
for l in sys.stdin:
a,b = map(int, l.split())
x,y = (a,b) if a > b else (b,a)
while x%y:
m = x % y
x,y = y,m
print "%d %d" % (y, a*b/y)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,689
|
s276366197
|
p00005
|
u813534019
|
1477162676
|
Python
|
Python
|
py
|
Accepted
| 10
|
6232
| 106
|
import sys
for l in sys.stdin:
x,y=map(int, l.split())
m=x*y
while x%y:x,y=y,x%y
print "%d %d"%(y,m/y)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,690
|
s012578797
|
p00005
|
u776559258
|
1477535148
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7680
| 175
|
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
while True:
try:
a,b=[int(i) for i in input().split()]
print(gcd(a,b),(a*b)//gcd(a,b))
except EOFError:
break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,691
|
s143629154
|
p00005
|
u659302741
|
1477734103
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7628
| 363
|
import sys
def gcd(a, b):
"?????§??¬?´???°????±???????"
if a < b:
c = a
a = b
b = c
if b == 0:
return a
else:
return gcd(b, a % b)
def lcm(a, b):
g = gcd(a, b)
return g * (a // g) * (b // g)
for line in sys.stdin:
a, b = map(int, line.split())
print("%d %d" % (gcd(a, b), lcm(a, b)))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,692
|
s528465898
|
p00005
|
u500396695
|
1477874618
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7700
| 286
|
import sys
dataset = sys.stdin.readlines()
def gcd(a, b):
if b > a: return gcd(b, a)
if a % b == 0: return b
return gcd(b, a % b)
def lcd(a, b):
return a * b // gcd(a, b)
for item in dataset:
a, b = list(map(int, item.split()))
print(gcd(a, b), lcd(a,b))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,693
|
s017432130
|
p00005
|
u500396695
|
1477874638
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7624
| 259
|
def GCD(a, b):
if b > a:
return GCD(b, a)
elif a % b == 0:
return b
return GCD(b, a % b)
def LCM(a, b):
return a * b // GCD(a, b)
import sys
L = sys.stdin.readlines()
for line in L:
x, y = list(map(int, line.split()))
print(GCD(x, y), LCM(x, y))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,694
|
s235032979
|
p00005
|
u149199817
|
1477974264
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7676
| 421
|
# -*- coding: utf-8 -*-
import sys
def gcd(a, b):
if a < b:
a, b = b, a
while b!=0:
c = b
b = a % b
a = c
return a
def lcm(a, b, g):
return a * b / g
def main():
for line in sys.stdin:
a, b = map(int, line.split())
ng = gcd(a, b)
nl = lcm(a, b, ng)
print('{0:d} {1:d}'.format(int(ng), int(nl)))
if __name__ == '__main__':
main()
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,695
|
s055825692
|
p00005
|
u886845205
|
1478197730
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7608
| 234
|
import sys
for line in sys.stdin:
n = [int(i) for i in line.replace("\n", "").split(" ")]
n.sort()
low = n[0]
hi = n[1]
while hi % low:
hi, low = low, hi % low
print("%d %d" % (low, n[0] / low * n[1]))
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,696
|
s199062400
|
p00005
|
u166871988
|
1478523957
|
Python
|
Python3
|
py
|
Accepted
| 40
|
7692
| 259
|
def gcd(li):
a=max(li)
b=min(li)
while b>0:
a,b=b,a%b
return a
def lcm(li):
return li[0]*li[1]/gcd(li)
while True:
try:
li=[int(i) for i in input().split(" ")]
print("%i %i"%(gcd(li),lcm(li)))
except:break
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,697
|
s229235272
|
p00005
|
u175111751
|
1478618700
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7604
| 263
|
def gcd(a, b):
if a == 0 or b == 0:
return 0
while b != 0:
a, b = b, a%b
return a
while True:
try:
a, b = map(int, input().split())
except EOFError:
break
else:
g = gcd(a,b)
print(g, a*b//g)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,698
|
s741532770
|
p00005
|
u660912567
|
1478730943
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7656
| 128
|
import sys
for line in sys.stdin:
a,b = list(map(int,line.split()))
ab = a*b
while b: a,b = b,a%b
print(a,ab//a)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,699
|
s123677152
|
p00005
|
u922871577
|
1479278976
|
Python
|
Python
|
py
|
Accepted
| 20
|
7792
| 127
|
import sys
from fractions import gcd
for line in sys.stdin:
a, b = map(int, line.split())
print gcd(a, b), a*b/gcd(a,b)
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,700
|
s129430195
|
p00005
|
u328069918
|
1479474615
|
Python
|
Python3
|
py
|
Accepted
| 50
|
10044
| 149
|
import sys
from fractions import gcd
[print("{} {}".format(gcd(*x), x[0] * x[1] // gcd(*x))) for x in [list(map(int, x.split())) for x in sys.stdin]]
|
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 < <var>a, b</var> ≤ 2,000,000,000</li>
<li> LCM(<var>a, b</var>) ≤ 2,000,000,000</li>
<li> The number of data sets ≤ 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,701
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.