20250902 baekjoon

This commit is contained in:
songyc macbook 2025-09-02 21:51:46 +09:00
parent 234b3de4a9
commit dc7c1fb0b3
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,5 @@
A, B = map(int, input().split())
temp = A*B
while B != 0 :
A, B = B, A%B
print(temp//A)

View File

@ -0,0 +1,18 @@
def gcd(n,m) :
temp = [n,m]
n = max(temp)
m = min(temp)
if m==0 :
return n
return gcd(m,n%m)
def lcm(n,m) :
return n*m//gcd(n,m)
a,b = map(int,input().split())
c,d = map(int,input().split())
denom = lcm(b,d)
num = a*(denom//b) + c*(denom//d)
factor = gcd(num, denom)
print(num//factor, denom//factor)

View File

@ -0,0 +1,6 @@
for _ in range(int(input())) :
A, B = map(int, input().split())
temp = A*B
while B != 0 :
A, B = B, A%B
print(temp//A)