Problem:


Score : 300 points

Problem Statement

Takahashi is organizing a party.

At the party, each guest will receive one or more snack pieces.

Takahashi predicts that the number of guests at this party will be A or B.

Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.

We assume that a piece cannot be divided and distributed to multiple guests.

Constraints

1 \leq A, B \leq 10^5

A \neq B

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.

Sample Input 1

2 3

Sample Output 1

6

When we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.

Sample Input 2

123 456

Sample Output 2

18696

Sample Input 3

100000 99999

Sample Output 3

9999900000



Sample input:
2 3


Sample output:
6

Submission status: Accepted

Solution code:
#python3
a, b = map(int, input().split())
def gcd(x, y):
  if x%y == 0:
    return y
  else :
    return gcd(y, x%y) 

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

print(lcm(a, b))

Submission status: Accepted

Solution code:
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while x % y > 0:
        x, y = y, x % y
    return y

A, B = list(map(int, input().split()))
g = gcd(A, B)
answer = int(A*B/g)
print(answer)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)
  
print(a * b // gcd(a, b))

Submission status: Accepted

Solution code:
def get_gcd(a, b):
    if a < b:
        a, b = b, a
    r = -1
    while r:
        r = a % b
        a = b
        b = r
    return a

a, b = map(int, input().split())
g = get_gcd(a, b)
ans = int(a * b / g)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
import numpy as np
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    A, B = rip()
    def gcd(a, b):
        return b if a == 0 else gcd(b % a, a)
    g = gcd(A, B)
    print(A // g * B)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from fractions import gcd

A,B = map(int, input().split())

print(int(A * B / gcd(A, B)))

Submission status: Accepted

Solution code:
a, b = input().split()
a = int(a)
b = int(b)
A = a
B = b
while 1:
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    if r == 0:
        GCD = b
        break
    a = b
    b = r
LCM = int(A*B/GCD)
print(LCM)

Submission status: Accepted

Solution code:
import fractions
A, B = map(int, input().split())
print((A * B) // fractions.gcd(A, B))

Submission status: Accepted

Solution code:
A, B = map(int, input().split(" "))

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

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

print(lcm(A, B))

Submission status: Accepted

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

  
li= list(map(int,input().strip().split()))

print(fun(li[0],li[1]))

Submission status: Accepted

Solution code:
a, b = map(int, input().split()) 
count = 1
 
while True:
    aaa = a * count
    if aaa % b == 0:
        print(aaa)
        break

    count += 1

Submission status: Accepted

Solution code:
import fractions

a,b=map(int,input().split())
print(int(a*b/fractions.gcd(a,b)))

Submission status: Accepted

Solution code:
import fractions

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

A, B = map(int, input().split(" "))

print(lcm(A, B))

Submission status: Accepted

Solution code:
from fractions import gcd

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

Submission status: Accepted

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

a, b = map(int, input().split())

c_a = 1

while True:
    if a*c_a%b == 0:
        break
    c_a += 1

print(a*c_a)

Submission status: Accepted

Solution code:
Ar =list(map(int,input().split()))

if Ar[0]>=Ar[1]:
  A=Ar[0]
  B=Ar[1]
else:
  A=Ar[1]
  B=Ar[0]

r=None
while r!=0:
  r = (A%B)
  A = B
  B = r

Ans=int(Ar[0]*Ar[1]/A)
print(Ans)

Submission status: Accepted

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

a, b = map(int, input().split())
c = max(a, b)
d = min(a, b)
n = 1
while True:
    if (c * n) %d == 0:
        break
    else:
        n += 1
    
print(c * n)

Submission status: Accepted

Solution code:
from fractions import gcd
a, b = map(int, input().split())

print(int(a*b / gcd(a, b)))

Submission status: Accepted

Solution code:
A, B = list(map(int, input().split(' ')))
max_div_val = 0
min_A_B = min(A, B)
for i in range(min_A_B):
    div_val = i + 1
    if A % div_val == 0 and B % div_val == 0:
        max_div_val = div_val
A_divisor = A // max_div_val
B_divisor = B // max_div_val
print(A_divisor * B_divisor * max_div_val)

Submission status: Accepted

Solution code:
import math


def euclid(A, B):
    n = max(A, B)
    m = min(A, B)
    while m > 0:
        k = n
        n = m
        m = k % m
    return n


def main():
    numbers = input().split(" ")
    A = int(numbers[0])
    B = int(numbers[1])
    print(round(A * B / euclid(A, B)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import fractions

a, b = map(int, input().split())
print(a * b//fractions.gcd(a, b))

Submission status: Accepted

Solution code:
# coding: utf-8


def greatest_common_divisor(bigger, smaller):
    
    if bigger < smaller:
        bigger, smaller = smaller, bigger
    while bigger % smaller != 0:
        bigger, smaller = smaller, bigger % smaller
    
    return smaller
    

def main():
    
    a, b = map(int, input().split(' '))
    least_common_multiple = a * b // greatest_common_divisor(a, b)
    print(least_common_multiple)
    
    return 0
    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import fractions

x,y = map(int,input().split()) 
G = fractions.gcd(x,y)
print(x*y//G)

Submission status: Accepted

Solution code:
'''input
123 456
'''
# A coding delight
from sys import stdin
from collections import defaultdict

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

# main starts
a, b = list(map(int, stdin.readline().split()))

print((a * b) // (gcd(a, b)))

Submission status: Accepted

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

A,B = map(int,input().split())
print((A*B)//gcd(A,B))

Submission status: Accepted

Solution code:
A, B = list(map(int, input().split()))
if A > B:
  n = A
else:
  n = B
q = list(range(1, n+1))
divisor = []
for i in q:
  if A % i == 0 and B % i == 0:
    divisor.append(i)
gcd = max(divisor)
lcm = int(A * B / gcd)
print(lcm)

Submission status: Accepted

Solution code:
# coding: utf-8
import fractions


def main():
    a, b = map(int, input().split(' '))
    
    print(a * b // fractions.gcd(a, b))
    
    return 0
    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def saidai_kouyakusu(a, b):
    a_ = max(a, b)
    b_ = min(a, b)
    q = a_ % b_
    if q == 0:
        return b_
    else:
        return saidai_kouyakusu(b_, q)
      
a, b = input().split()
a = int(a)
b = int(b)
print(a * b // saidai_kouyakusu(a, b))

Submission status: Accepted

Solution code:
A, B = map(int, input().split())

a, b = A, B
while a != b:
    if a < b:
        a += A
    else:
        b += B

print(a)

Submission status: Accepted

Solution code:
input_line = input().split(' ')
numA = int(input_line[0])
numB = int(input_line[1])

def gcd(a, b):
  if b > a:
    tmp = b
    b = a
    a = tmp
  while True:
    rem = a % b
    if rem == 0:
      break
    else:
      a = b
      b = rem
  return b

gcd = gcd(numA, numB)
divA = numA // gcd
divB = numB // gcd

print(gcd * divA * divB)

Submission status: Accepted

Solution code:
import fractions

a,b = map(int,input().split())

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

print(lcm(a, b))

Submission status: Accepted

Solution code:
import fractions

a, b = map(int, input().split())
gcd = fractions.gcd(a, b)
print(a * b // gcd)

Submission status: Accepted

Solution code:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
lcm = (A * B) // gcd
print(lcm)

Submission status: Accepted

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

A, B = [int(x) for x in input().split()]


def saisho_kouyakusu(a, b):
    a, b = max(a, b), min(a, b)
    if a%b==0:
        return b
    else:
        return saisho_kouyakusu(b,a%b)

skys=saisho_kouyakusu(A,B)
Ad=A/skys
print(int(Ad*B))

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
if A > B:
    G = A
    S = B
else:
    G = B
    S = A
ans = G
while ans % S != 0:
    ans += G

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

A, B, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

print(A * B // gcd(A, B))

Submission status: Accepted

Solution code:
# Snack
from collections import deque
import numpy as np
import math


# input
A, B = map(int, input().split())
A, B = max(A,B), min(A,B)

# solve
# -----------------
# 約数列挙
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = deque()
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return list(divisor_list)
# -----------------

div_A = make_divisor_list(A)
div_B = make_divisor_list(B)

rem = [b for b in div_B if b not in div_A]

if len(rem) != 0:
    for b in [b for b in div_B if b not in div_A]:
        if A * b % B == 0:
            res = A * b
            break
else:
    res = A

# output
print(res)

Submission status: Accepted

Solution code:
from fractions import gcd
x,y = map(int,input().split())
print((x * y) // gcd(x, y))

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

A,B=LI()
print(A*B//gcd(A,B))

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
i = 1
while True:
    if (A * i) % B == 0:
        print(A * i)
        exit(0)
    i += 1

Submission status: Accepted

Solution code:
import fractions
a,b = map(int,input().split())

g = a*b/fractions.gcd(a,b)
print(int(g))

Submission status: Accepted

Solution code:
import fractions
i=list(map(int, input().split()))
a=i[0]
b=i[1]
c=fractions.gcd(a,b)
print(i[0]*i[1]//c)

Submission status: Accepted

Solution code:
import fractions
a,b = map(int,input().split())
gcd = fractions.gcd(a,b)
print(gcd*(a//gcd)*(b//gcd))

Submission status: Accepted

Solution code:
import fractions


class Solution:
    def solve(self, a: int, b: int) -> int:

        return a * b // fractions.gcd(a, b)


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))

Submission status: Accepted

Solution code:
def pgcd(a,b):
    if b==0:
        return a
    else:
        return pgcd(b,a%b)
def ppcm(a,b):
    return (a*b)//pgcd(a,b)
a,b=map(int,input().split())
print(ppcm(a,b))

Submission status: Accepted

Solution code:
import fractions

s = list(input().split())

participants_num_A = int(s[0])
participants_num_B = int(s[1])

print(participants_num_A * participants_num_B // fractions.gcd(participants_num_A, participants_num_B))

Submission status: Accepted

Solution code:
import fractions
a, b = map(int,input().split())
def jk(j,k):
    return j*k//fractions.gcd(j,k)
print(jk(a, b))

Submission status: Accepted

Solution code:
a, b = (int(x) for x in input().split())
if a > b:
    c = a
    a = b
    b = c
ans = a
c = b
while True:
    if ans == c: break
    elif ans > c: c += b
    ans += a
print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd

A, B = map(int, input().split())
res = A * B // gcd(A, B)

print(res)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
print(a*b // gcd(a,b))

Submission status: Accepted

Solution code:
from fractions import gcd

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

a, b = map(int, input().split())
print(lcm(a,b))

Submission status: Accepted

Solution code:
import fractions

a, b = map(int, input().split())

print(int((a * b) // fractions.gcd(a,b)))

Submission status: Accepted

Solution code:
a,b = map(int, input().split())

def gcd(n,m):
    while m:
        n, m = m, n % m
    return n

def lcm(n,m):

    return (n*m) // gcd(n,m)

print(lcm(a,b))

Submission status: Accepted

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

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

a, b = map(int, input().split())
print(lcm(a,b))

Submission status: Accepted

Solution code:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))

Submission status: Accepted

Solution code:
import fractions

a,b=map(int,input().split())

print(a*b//fractions.gcd(a, b))

Submission status: Accepted

Solution code:
import sys
a, b = input().split()

A = int(a)
B = int(b)

Adiv = A
Bdiv = B
k = 0




for i in reversed(range(min([A, B]))):
    j = i+1
    if Adiv % j == 0 and Bdiv % j == 0:
        k = j
        break


if k == 0:
    k = 1


res = A * B / k

print(int(res))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
#n=int(input())
#s,t=list(input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
print(a*b//gcd(a,b))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
gcd=1
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        gcd=i
print(a*b//gcd)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
i = 1
while True:
  if a * i % b == 0:
    print(str(a*i))
    break
  else:
    i += 1

Submission status: Accepted

Solution code:
from fractions import gcd

a,b = map(int,input().split())

def main():
    tmp = gcd(a,b)
    print(tmp*(a//tmp)*(b//tmp))
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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


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


def main():
    A, B = map(int, input().split())
    print(lcm(A, B))
    return


main()

Submission status: Accepted

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


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


def main():
    A, B = map(int, input().split())
    print(lcm(A, B))
    return


main()

Submission status: Accepted

Solution code:

A, B = [int(i) for i in input().split(" ")]
i = 1
while(True):

    if A*i % B ==0:
        print(A*i)
        break

    i += 1

Submission status: Accepted

Solution code:
def calc_gcd(a, b):
    r = a % b
    while (r != 0):
        a = b
        b = r
        r = a % b

    return b

a, b = list(map(int, input().split()))

if a < b:
    tmp = a
    a = b
    b = tmp

gcd = calc_gcd(a, b)
ans = int(a * b / gcd)

print(ans)

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())


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

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

print(lcm(a,b))

Submission status: Accepted

Solution code:
import fractions
a, b = map(int, input().split())
print(a*b//fractions.gcd(a, b))

Submission status: Accepted

Solution code:
import fractions

A, B = map(int, input().split())

print(A * B // fractions.gcd(A, B))

Submission status: Accepted

Solution code:
import fractions
A, B = map(int, input().split())

GCD = fractions.gcd(A, B)
LCM = A * B // GCD
print(LCM)

Submission status: Accepted

Solution code:
import fractions

A,B = map(int,input().split())

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

print(int(lcm(A, B)))

Submission status: Accepted

Solution code:
A,B = map(int,input().split())

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

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

print(int(lcm(A,B)))

Submission status: Accepted

Solution code:
import operator
import functools

A, B = input().split()

A = int(A)
B = int(B)

value = []

count = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

primeA = prime_factorize(A)

primeB = prime_factorize(B)


for i in range(len(primeA)):
    for j in range(len(primeB)):
        if primeA[i] == primeB[j]:
            value.append(primeA[i])
            primeA[i] = 1
            primeB[j] = 1
            break
        else:
            continue

value = value + primeA + primeB

result = functools.reduce(operator.mul, value)

print(result)

Submission status: Accepted

Solution code:
A, B = map(int, raw_input().split())

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

print A * B / gcd(A, B)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

i = 1
while(True):
    if (a * i) % b == 0:
        ans = a * i
        break
    i += 1

print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

i = 1
flag = True
while(flag):
    if (a * i) % b == 0:
        flag = False
        ans = a * i
        break
    i += 1

print(ans)

Submission status: Accepted

Solution code:
import math
a, b = map(int, input().split())

i = 1
flag = True
while(flag):
    if (a * i) % b == 0:
        flag = False
        ans = a * i
        break
    i += 1

print(ans)

Submission status: Accepted

Solution code:
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
a = list(map(int, input().split()))

print(a[0]*a[1]//fractions.gcd(a[0], a[1]))

Submission status: Accepted

Solution code:
A,B = (int(i) for i in input().split())

import fractions

def lcm(a, b):
    #return a * b // math.gcd(a, b)
    return  a*b // fractions.gcd(a, b)

print(lcm(A,B))

Submission status: Accepted

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

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


a, b = map(int, input().split())
print(lcm(a, b))

Submission status: Accepted

Solution code:
import fractions
a, b = map(int, input().split())
print(int(a * b / fractions.gcd(a, b)))

Submission status: Accepted

Solution code:
A, B = map(int, input().split())

import fractions 

print(A * B // fractions.gcd(A, B))

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
for i in range(1, b+1):
    if i*a % b == 0:
        print(i*a)
        break

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    else:
      return gcd(b,a%b)
g=gcd(A,B)
print(int(A*B/g))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

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

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

print(lcm(a, b))

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
a,b = A,B
while True:
    if a > b:
        b += B
    elif a < b:
        a += A
    if a == b:
        print(a)
        break