20250626 baekjoon

This commit is contained in:
songyc macbook 2025-06-26 21:35:19 +09:00
parent 97f391f309
commit 387d4b1227
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d",&a, &b);
if(a<b) {
int temp;
temp = a;
a = b;
b = temp;
}
int gcd = a, b_temp = b, r;
while(b_temp != 0) {
r = gcd % b_temp;
gcd = b_temp;
b_temp = r;
}
int lcm = a*b/gcd;
printf("%d\n%d\n",gcd,lcm);
return 0;
}

View File

@ -0,0 +1,7 @@
let [a,b] = require("fs").readFileSync(0,"utf8").toString().trim().split(' ').map(Number);
if(a<b) [a,b] = [b,a];
const GCD = (x,y) => y!==0 ? GCD(y, x%y) : x;
const gcd = GCD(a,b);
const lcm = a*b/gcd;
console.log(gcd);
console.log(lcm);

View File

@ -0,0 +1,5 @@
a, b = map(int, input().split())
x, y = max(a,b), min(a,b)
while y :
x, y = y, x%y
print(f"{x}\n{a*b//x}")