submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s616632997 | p00005 | Time Limit Exceeded | import itertools
while 1:
try:
a, b= map(int, raw_input().split())
GCD = a * b
LCM = 0
# GCD
for i, j in itertools.product(range((a if a > b else b) / 2), repeat=2):
if a * (i+1) == b * (j+1) and GCD > a * (i+1):
GCD = a * (i+1)
# LCM
flag = 0
for i in range(a if a > b else b, 1, -1):
if a % i == 0 and b % i == 0 and flag == 0:
LCM = i
flag += 1
print "{} {}".format(str(GCD), str(LCM))
except:
break | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s853973333 | p00005 | Memory Limit Exceeded | import sys
for ab in sys.stdin:
a,b=map(int,ab.split(" "))
if a>=b:
for g in range(b,0,-1):
if a%g==0 and b%g==0:
gcd = g
break
for l in range(1,b+1):
if (a*l)%b == 0:
lcm = a*l
break
else:
for g in range(a,0,-1):
if a%g==0 and b%g==0:
gcd = g
break
for l in range(1,a+1):
if (b*l)%a == 0:
lcm = b*l
break
print gcd,lcm | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s587290919 | p00005 | Memory Limit Exceeded | import sys
def main():
for input_line in sys.stdin:
num1 = int(input_line.split(' ')[0])
num2 = int(input_line.split(' ')[1])
if num1 <= num2:
dividend(num1, num2, num1)
elif num1 > num2:
dividend(num1, num2, num2)
result.sort(reverse=True)
greatest_common_divisor = result[0]
least_common_multiple = num1 * num2 / greatest_common_divisor
print('%s %s' % (greatest_common_divisor, least_common_multiple))
def dividend(num1, num2, num):
for i in range(num):
divisor = i+1
if num1 % divisor == 0 and num2 % divisor == 0:
result.append(divisor)
if __name__ == '__main__':
result = []
main() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s088313185 | p00005 | Memory Limit Exceeded | 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
for i in list(reversed(range(2, x))):
if (x % i) == 0 and (y % i) == 0:
x = x / i
y = y / i
largest *= i
smallest = largest * (a/largest) * (b/largest)
print('%d %d' % (largest, smallest))
largest = 1 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s335759841 | p00005 | Memory Limit Exceeded | #coding: utf-8
import sys
for line in sys.stdin:
l = (map(int,line.split()))
l.sort()
a = l[0]
b = l[1]
for i in range(2,a+1):
if a%i == 0 and b%i == 0:
ans = i
print a*b/ans,ans | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s716281496 | p00005 | Memory Limit Exceeded | def calc(a,b):
yakusuu = []
for i in range(1, a + 1):
if a % i == 0:
yakusuu.append(i)
maxi = 1
for j in yakusuu:
if b % j == 0:
maxi = j
mini = maxi * a/maxi * b/maxi
print maxi, int(mini)
while True:
try:
a, b =map(int, raw_input().split())
except:
break
if a > b:
a, b = b, a # a < b
calc(a,b) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s190591186 | p00005 | Memory Limit Exceeded | while True:
a,b = map(int, sorted(raw_input().split()))
# GCD
for i in range(a, 1, -1):
if a%i == 0 and b%i == 0:
GCD = i
break
# LCM
for i in range(1, a+1):
print i
if (b * i) % a == 0:
LCM = b * i
break
print " ".join(map(str,[GCD, LCM])) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s483568713 | p00005 | Memory Limit Exceeded | while True:
try:
a,b = map(int, sorted(raw_input().split()))
# GCD
for i in range(a, 1, -1):
if a%i == 0 and b%i == 0:
GCD = i
break
# LCM
for i in range(1, a+1):
if (b * i) % a == 0:
LCM = b * i
break
print " ".join(map(str,[GCD, LCM]))
except EOFError:
break | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s996871518 | p00005 | Memory Limit Exceeded | while True:
try:
a,b = map(int, sorted(raw_input().split()))
# GCD
for i in range(a, 1, -1):
if a%i == 0 and b%i == 0:
GCD = i
break
# LCM
for i in range(1, a+1):
if (b * i) % a == 0:
LCM = b * i
break
print " ".join(map(str,[GCD, LCM]))[:-1]
except EOFError:
break | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s487130866 | p00005 | Accepted | import math
while True:
try:
a,b=map(int,input().split())
print(*[math.gcd(a,b),a*b//math.gcd(a,b)])
except:break
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s594523890 | p00005 | Accepted | def gcd(a,b):
while b != 0:
a, b = b, a % b
return a
while True:
try:
a, b = map(int, raw_input().split())
print gcd(a, b), a*b/ gcd(a,b)
except:
break
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s489812382 | p00005 | Accepted | import math
while True:
try:
a,b = map(int,input().split())
print(math.gcd(a,b),a*b//math.gcd(a,b))
except:
break
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s535279251 | p00005 | Accepted | def gcd(n1,n2):
if n2==0:
return n1
return gcd(n2,n1%n2)
def lcm(n1,n2):
return n1/gcd(n1,n2)*n2
while True:
try:
a,b=[int(i) for i in input().split()]
print("{} {}".format(int(gcd(a,b)),int(lcm(a,b))))
except:
break
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s357597334 | p00005 | Accepted | import sys
while 1:
line = sys.stdin.readline()
if (not line):
break
x, y = map(int, line.split())
if (x > y):
gcd = x
t = y
else :
gcd = y
t = x
while (t > 0) :
tmp = gcd % t
gcd = t
t = tmp
lcm = x * y / gcd
print str(gcd) + " " + str(lcm) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s185329253 | p00005 | Accepted | import sys
def gcd(a,b):
if b == 0: return a
else: return gcd(b,a%b)
for i in sys.stdin:
a, b = map(int, i.split())
g = gcd(a,b)
print g, a/g*b | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s388716206 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s676871032 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s471180467 | p00005 | Accepted | 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
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s382347874 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s442052527 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s108100200 | p00005 | Accepted | #!/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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s649961189 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s729751320 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s682851452 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s953916803 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s307455414 | p00005 | Accepted | 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; | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s817205162 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s807019739 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s857108393 | p00005 | Accepted | 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() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s363389679 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s658715084 | p00005 | Accepted | # -*- 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s400197197 | p00005 | Accepted | # -*- 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s229344128 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s925341148 | p00005 | Accepted | #!/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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s976595098 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s583376546 | p00005 | Accepted | #! /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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s377624064 | p00005 | Accepted | #! /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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s745559165 | p00005 | Accepted | 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]))
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s785996369 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s869598072 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s154745189 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s774985976 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s419397400 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s653927191 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s178303923 | p00005 | Accepted | # 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s745082628 | p00005 | Accepted | # -*- 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 ) ) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s053365507 | p00005 | Accepted | 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]) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s583583638 | p00005 | Accepted | 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]) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s627790169 | p00005 | Accepted | 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]) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s181649771 | p00005 | Accepted | #!/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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s792347346 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s100640323 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s592393420 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s914336626 | p00005 | Accepted | # 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s151492802 | p00005 | Accepted |
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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s624257525 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s723465919 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s050250706 | p00005 | Accepted | # -*- 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() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s389150867 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s962954377 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s275695962 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s684193415 | p00005 | Accepted | 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))) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s354030225 | p00005 | Accepted | # 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s716892037 | p00005 | Accepted | 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])))) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s644606617 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s180888429 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s769259066 | p00005 | Accepted | 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() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s735046386 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s933679176 | p00005 | Accepted | # 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)) )
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s588480652 | p00005 | Accepted | 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])) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s488877311 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s029805107 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s799407605 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s892655837 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s340260863 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s122713376 | p00005 | Accepted | #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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s882970591 | p00005 | Accepted | # -*- 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s314229595 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s740155215 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s719905403 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s301140190 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s395391076 | p00005 | Accepted | #!/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() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s250144866 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s341537607 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s662786124 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s474401310 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s020961007 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s277840971 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s110221036 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s537113689 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s692082649 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s970523655 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s232400621 | p00005 | Accepted | 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() | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s205750271 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s931061991 | p00005 | Accepted | 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()
| 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s183593460 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s971644278 | p00005 | Accepted | 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)) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s830777507 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s819664381 | p00005 | Accepted | 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 | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
s823452844 | p00005 | Accepted | 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) | 8 6
50000000 30000000
| 2 24
10000000 150000000
|
<H1>GCD and LCM</H1>
<p>
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>.
</p>
<H2>Input</H2>
<p>
Input consists of several data sets. Each data set contains <var>a</var> 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>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.